nginx as reverse proxy
-
I've been searching as much as possible, and I can't seem to get to the bottom of my issue.
I've got nodebb working on Debian wheezy. It's up and running, and working on the direct IP:port. You can save / edit and can see sockets connected
I've set up nginx (1.6) as a reverse proxy, and it's loading the site, you can browse etc, but can't save anything.
Can't see any socket data.
The only errors I'm getting in the logs are relating to Upstream Timed Out
I've tried setting nodebb to listed on the loopback address and public address, and the results are the same.
nginx config:
Any suggestions, as I'd really like to give this a proper try.
Thanks,
-
Never mind..........feel dumb now.
I installed nodebb as the root user, and was running it root. I've re-installed it using the nginx user, and started it as nginx, and it's working now
EDIT: Actually....that's not fixed it
-
@Matt-Worthington Have you gone back into nodebb setup and set use port to false?
Is your forum about "Werkin int pit?"
Oh and your proxy pass doesn't look right, but I'm not 100% on that.
-
@a_5mith I tried various things with Proxy Pass. I've just spun up a new DO droplet to build again, and I'm getting the same results.
This is the config that it generated when setting it up:
{
"base_url": "http://nodebb.matt1206.co.uk",
"port": "4567",
"use_port": false,
"secret": "bd66b3f6-08f9-4efa-947d-4b9df5afb2da",
"bind_address": "127.0.0.1",
"database": "redis",
"redis": {
"host": "127.0.0.1",
"port": "6379",
"password": "",
"database": "0"
},
"bcrypt_rounds": 12,
"upload_path": "/public/uploads",
"use_port": false,
"relative_path": ""
}
I'm currently using this server block on the new VPSserver {
listen 188.226.168.176:80;
server_name nodebb.matt1206.co.uk;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_pass http://127.0.0.1:4567/; proxy_redirect off; #Socket.IO Support proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; }
}
-
Let your
proxy_pass
andserver
in Nginx config match yourbase_url
in NodeBB config. -
@planner Getting 502 bad gateway with that set
server { listen 188.226.168.176:80; server_name nodebb.matt1206.co.uk; 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_pass http://nodebb.matt1206.co.uk:4567/; proxy_redirect off; #Socket.IO Support proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; } }
Swapping back to 127.0.0.1:4567 for the proxy pass lets the site load, but still can't post.
Errors from nginx log:
2014/06/05 14:46:43 [error] 9016#0: *1 upstream timed out (110: Connection timed out) while reading response header from upstream, client: 195.188.150.130, server: nodebb.matt1206.co.uk, request: "GET /socket.io/1/xhr-polling/p0GniusC-j-O43V2b2v-?t=1401979543995 HTTP/1.1", upstream: "http://127.0.0.1:4567/socket.io/1/xhr-polling/p0GniusC-j-O43V2b2v-?t=1401979543995", host: "nodebb.matt1206.co.uk", referrer: "http://nodebb.matt1206.co.uk/"
-
First server:
root@debian:~/.ssh# nginx -V
nginx version: nginx/1.6.0
built by gcc 4.7.2 (Debian 4.7.2-5)
TLS SNI support enabled
configure arguments: --with-cc-opt='-g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2' --with-ld-opt=-Wl,-z,relro --prefix=/usr/share/nginx --conf-path=/etc/nginx/nginx.conf --http-log-path=/var/log/nginx/access.log --error-log-path=/var/log/nginx/error.log --lock-path=/var/lock/nginx.lock --pid-path=/run/nginx.pid --http-client-body-temp-path=/var/lib/nginx/body --http-fastcgi-temp-path=/var/lib/nginx/fastcgi --http-proxy-temp-path=/var/lib/nginx/proxy --http-scgi-temp-path=/var/lib/nginx/scgi --http-uwsgi-temp-path=/var/lib/nginx/uwsgi --with-debug --with-pcre-jit --with-ipv6 --with-http_ssl_module --with-http_stub_status_module --with-http_realip_module --with-http_auth_request_module --with-file-aio --with-http_spdy_module --with-http_addition_module --with-http_dav_module --with-http_geoip_module --with-http_gzip_static_module --with-http_image_filter_module --with-http_secure_link_module --with-http_sub_module --with-http_xslt_module --with-mail --with-mail_ssl_module --add-module=/usr/src/nginx/source/nginx-1.6.0/debian/modules/nginx-auth-pam --add-module=/usr/src/nginx/source/nginx-1.6.0/debian/modules/nginx-dav-ext-module --add-module=/usr/src/nginx/source/nginx-1.6.0/debian/modules/nginx-echo --add-module=/usr/src/nginx/source/nginx-1.6.0/debian/modules/nginx-upstream-fair --add-module=/usr/src/nginx/source/nginx-1.6.0/debian/modules/nginx-syslog --add-module=/usr/src/nginx/source/nginx-1.6.0/debian/modules/nginx-cache-purge --add-module=/usr/src/nginx/source/nginx-1.6.0/debian/modules/ngx_http_pinba_module --add-module=/usr/src/nginx/source/nginx-1.6.0/debian/modules/ngx_http_substitutions_filter_module --add-module=/usr/src/nginx/source/nginx-1.6.0/debian/modules/nginx-x-rid-header --with-ld-opt=-lossp-uuid2nd Server
root@test:/var/log/nginx# nginx -V
nginx version: nginx/1.7.1
built by gcc 4.7.2 (Debian 4.7.2-5)
TLS SNI support enabled
configure arguments: --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp --user=nginx --group=nginx --with-http_ssl_module --with-http_realip_module --with-http_addition_module --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_random_index_module --with-http_secure_link_module --with-http_stub_status_module --with-http_auth_request_module --with-mail --with-mail_ssl_module --with-file-aio --with-http_spdy_module --with-cc-opt='-g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2' --with-ld-opt='-Wl,-z,relro -Wl,--as-needed' --with-ipv6 -
I've just reconfigure nodebb to listen on the public address:
http://nodebb.matt1206.co.uk:4567/ - works fine, can post, create new categories etc.
http://nodebb.matt1206.co.uk - loads, can browse, but can't post, create categories
upstream nodejs {
server 188.226.168.176:4567;
}server {
listen 188.226.168.176:80;
server_name nodebb.matt1206.co.uk;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_pass http://nodejs; proxy_redirect off; #Socket.IO Support proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; }
}
-
@Matt-Worthington said:
http://nodebb.matt1206.co.uk - loads, can browse, but can't post, create categories
Well, that's progress. At least you know it works - partially. Check your Nginx error log for clues to what's happening when you try to post or create categories. Also check your browser's Web console.
-
@planner That has always been the case. The site has always been loading. Same for this one (http://sheffieldfitnessforum.co.uk/)
Web console:
Error logs:
2014/06/05 08:20:37 [error] 29679#0: *15 upstream timed out (110: Connection timed out) while reading response header from upstream, client: 195.188.150.130, server: sheffieldfitnessforum.co.uk, request: "GET /socket.io/1/xhr-polling/kxJx3zLShgZbkiM5u12C?t=1401952789255 HTTP/1.1", upstream: "http://127.0.0.1:4567/socket.io/1/xhr-polling/kxJx3zLShgZbkiM5u12C?t=1401952789255", host: "sheffieldfitnessforum.co.uk", referrer: "http://sheffieldfitnessforum.co.uk/admin/index"
2014/06/05 08:22:08 [error] 29679#0: *132 upstream timed out (110: Connection timed out) while reading response header from upstream, client: 195.188.150.130, server: sheffieldfitnessforum.co.uk, request: "GET /socket.io/1/xhr-polling/DBYXQx5k-LBDONRXu12E?t=1401952880125 HTTP/1.1", upstream: "http://127.0.0.1:4567/socket.io/1/xhr-polling/DBYXQx5k-LBDONRXu12E?t=1401952880125", host: "sheffieldfitnessforum.co.uk", referrer: "http://sheffieldfitnessforum.co.uk/admin/index" -
@julian said:
@Matt-Worthington Earlier, I did manage to register, although I didn't try posting. Seemed to be working fine for me.
Latest version of NodeBB, or 0.4.3?
You are running NodeBB v0.4.3.
You are up-to-dateIf you go here : http://sheffieldfitnessforum.co.uk/register
error log from trying to register
2014/06/05 16:24:52 [error] 16521#0: *1729 upstream timed out (110: Connection timed out) while reading response header from upstream, client: 195.188.150.130, server: sheffieldfitnessforum.co.uk, request: "GET /socket.io/1/xhr-polling/mjmVf8jqrKdPP4u79DC2?t=1401981844875 HTTP/1.1", upstream: "http://127.0.0.1:4567/socket.io/1/xhr-polling/mjmVf8jqrKdPP4u79DC2?t=1401981844875", host: "sheffieldfitnessforum.co.uk", referrer: "http://sheffieldfitnessforum.co.uk/register" -
I can post if I use this URL : http://sheffieldfitnessforum.co.uk:4567/
I can't post if I use this URL : http://sheffieldfitnessforum.co.uk/ -
@Matt-Worthington Seems to be working fine... so at the very least perhaps we can rule out a problem on the server end?