[英]nginx as reverse proxy for express server 504 Gateway Time-out
[英]504 Gateway Time-out nginx/1.4.6 (Ubuntu) in Node.js and nginx
我正在使用Nginx測試示例節點應用程序。
但是我收到504網關超時。 nginx / 1.4.6(Ubuntu 14.04)
我看到其他與同一主題相關的帖子,但沒有用。
以下是我在Azure上安裝節點nginx所遵循的過程。
curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash -
sudo apt-get install -y nodejs
sudo apt-get install -y build-essential
curl -Lo hello.js http://do.co/node-hello
sudo nano app.js
app.js文件
var http = require('http');
http.createServer(function (req, res) {
console.log('Came here');
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('Hello World\n');
}).listen(8080, 'localhost');
console.log('Server running at http://localhost:8080/');
ls -l
-rwxrwxrwx 1 root root 265 Mar 12 15:52 app.js
sudo npm install pm2 -g
pm2 startup
sudo env PATH=$PATH:/usr/bin /usr/lib/node_modules/pm2/bin/pm2 startup upstart -u azureuser --hp /home/azureuser
pm2 start app.js
Nginx Server
sudo apt-get update
sudo apt-get install nginx
sudo nano /etc/nginx/sites-available/default
sudo nano / etc / nginx / sites-available /默認文件
server {
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;
root /usr/share/nginx/html;
index index.html index.htm;
server_name testingnode.cloudapp.net;
location / {
proxy_pass http://13.65.148.35:8080;
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;
}
}
sudo service nginx restart
在天藍色的儀表板中打開了HTTP端口80
因此,在嘗試運行http://13.65.148.35/或testingnode.cloudapp.net的所有配置之后,將給出504超時。
如果需要為使用Nginx運行節點配置任何內容,請讓我。
在您的nginx配置中,更改行proxy_pass http://13.65.148.35:8080;
到proxy_pass http://127.0.0.1:8080;
您正在為代理傳遞提供外部可訪問的IP,因此nginx將按照與外部用戶相同的方式遵守防火牆設置。 即無法訪問端口8080。請確保其在服務器的本地范圍內進行通信。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.