2017-06-05 63 views
1

我有一個redhat Ec2實例。我有一個簡單的Express App在port 3000上運行。我安裝了nginx,它運行正常,因爲我可以將s3桶靜態網站代理到我正在使用的其他子域。但是,當我嘗試將我的快速應用程序代理到其中一個子域時,我一直在獲取nginx失敗頁面。這裏是我的nginx的配置塊,我使用:無法讓節點服務器代理到RedHat Ec2實例上的nginx

server { 
    listen  80; 
    listen  api.subdoamin.com:80; 
    server_name api.grouve.tech; 
    root   /usr/share/nginx/html; 

    # Load configuration files for the default server block. 
    include /etc/nginx/default.d/*.conf; 

    location/{ 
      proxy_pass http://00.000.00.000:3000; 
      expires 1y; 
      log_not_found off; 
      proxy_http_version 1.1; 
      proxy_set_header Upgrade $http_upgrade; 
      proxy_set_header Connection 'upgrade'; 
      proxy_set_header Host $host; 
      proxy_cache_bypass $http_upgrade; 
    } 
    error_page 404 /404.html; 
     location = /40x.html { 
    } 

    error_page 500 502 503 504 /50x.html; 
     location = /50x.html { 
    } 
} 
+1

的節點和nginx的同一實例上運行? –

+0

是的,他們在同一個實例上運行。我的節點應用程序運行在/ opt/api –

+0

然後您應該嘗試使用'proxy_pass http://127.0.0.1:3000;' –

回答

1

由於@DusanBajic答案是sudo setenforce 0

+0

請記住,此修復無法在重新啓動後存活,您需要永久禁用selinux([fedora](https://docs.fedoraproject.org/en-US/Fedora/11/html/Security-Enhanced_Linux) /sect-Security-Enhanced_Linux-Enabling_and_Disabling_SELinux-Disabling_SELinux.html),[centos](https://www.centos.org/docs/5/html/5.1/Deployment_Guide/sec-sel-enable-disable.html)) –

+0

謝謝@DusanBajic –

相關問題