Good day ! There are 10 VMs, sites work for them, and reverse proxying is implemented via nginx. It was important to have ssl at the same time, so in the nginx settings, namely in the /etc/nginx/nginx.conf file, it looks like this: (1.1.1.1 - IP of the VM on which the site runs)
server { listen 443 ssl; listen 80 ; server_name domen.com; ssl_certificate /etc/nginx/ssl/domen.com.crt; ssl_certificate_key /etc/nginx/ssl/domen.com.key; ssl_protocols TLSv1 TLSv1.1 TLSv1.2; ssl_ciphers HIGH:!aNULL:!MD5; reset_timedout_connection on; if ($scheme = http) { return 301 https://$server_name$request_uri; } location ~* / { proxy_pass http://1.1.1.1:8080; proxy_pass_request_headers on; } }
There were 11 VMs, but unfortunately, it didn’t work out to implement proxying in this way. It is only necessary to remove SSL - and everything works correctly. At 11 VM, pm2 deploys two applications (app1 and app2) of node.js, the first is 11.11.11.11:8081, and the second is 11.11.11:8082. The record for proxying these applications looks like this (you need to get app1 at domen.com, app2 - domen.com/app2):
server { listen 443 ssl; listen 80 ; server_name domen.com; ssl_certificate /etc/nginx/ssl/domen.com.crt; ssl_certificate_key /etc/nginx/ssl/domen.com.key; ssl_protocols TLSv1 TLSv1.1 TLSv1.2; ssl_ciphers HIGH:!aNULL:!MD5; location / { access_log off; proxy_pass http://11.11.11.11:8081/; 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; } location /app2/ { access_log off; proxy_pass http://11.11.11.11:8082/; 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; } }
App1 - works fine, but app2 with https cannot work correctly, and when working on http, everything is fine. Tell me, please, what could be the problem?
The problem was that you needed to proxy socket.io separately