0
我創建了一個使用Google身份驗證的Node.js網站。該網站被100多個用戶同時使用,影響性能。所以我明白Nginx可以通過在多個端口中創建Node.js應用程序的多個實例來幫助擴展網站,然後我們使用Nginx作爲負載平衡器。Nginx使用Node.js和Google Oauth進行負載均衡
因此,我配置了Nginx,但問題是它似乎不適用於Google身份驗證。我能夠看到我的網站的第一頁,我可以通過谷歌登錄,但在這一點之後,這是不起作用的。
任何建議,可能會失蹤,使這項工作。
這是我的配置文件:
upstream my_app
{
least_conn; # Use Least Connections strategy
server ip:3001; # NodeJS Server 2 I changed the actual ip
server ip:3002; # NodeJS Server 3
server ip:3003; # NodeJS Server 4
server ip:3004; # NodeJS Server 5
keepalive 256;
}
server {
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;
expires epoch;
add_header Cache-Control "no-cache, public, must-revalidate, proxy-revalidate";
server_name ip;
access_log /var/log/nginx/example.com-access.log;
error_log /var/log/nginx/example.com-error.log error;
# Browser and robot always look for these
# Turn off logging for them
location = /favicon.ico { log_not_found off; access_log off; }
location = /robots.txt { log_not_found off; access_log off; }
# pass the request to the node.js server
# with some correct headers for proxy-awareness
location/{
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header X-NginX-Proxy true;
proxy_buffers 8 16k;
proxy_buffer_size 32k;
proxy_pass http://my_app ;
proxy_redirect off ;
add_header Pragma "no-cache";
# Handle Web Socket connections
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
}
我剛開始學習關於nginx的,我檢查時,上游只有一個IP地址,這是工作。即它作爲一個反向代理,但不作爲負載平衡器,我的猜測是由於谷歌認證性質。
而我在錯誤日誌中收到的錯誤是連接被拒絕。 謝謝。
嗨凱西,你爲什麼不告訴我們一些代碼,想知道你到目前爲止嘗試過什麼? – Flip
你的意思是Nginx的配置? –