Nginx : Reverse Proxy Settings#22015/08/18 |
Configure Nginx for Reverse Proxy Settings which also forwards WebSocket.
|
|
[1] | For example, configure Nginx to set proxy on /chat for an application which works on port 1337 of backend server. The sample application is from here (section [3]). |
[root@www ~]#
vi /etc/nginx/nginx.conf # change like follows in "server" section server { listen 80 default_server; listen [::]:80 default_server; server_name www.srv.world; location /socket.io/ { proxy_pass http://node01.srv.world:1337/socket.io/; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; } location /chat { proxy_pass http://node01.srv.world:1337/; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; } location / { proxy_pass http://node01.srv.world/; } }[root@www ~]# systemctl restart nginx |
[2] | If SELinux isenabled, allow port for application. |
[root@www ~]# semanage port -a -t http_port_t -p tcp 1337 |
[3] | Access to the sample App to make sure it works normally on proxy environment. |
Sponsored Link |