How to configure Nginx reverse for Unity server (Mirror) proxy without Wss or Https?

212 views Asked by At

In order to get a dedicated server for a MMO game made in Unity for WEBGL, is handy to configure an Nginx reverse proxy on the server. Out there is plenty of examples for reverse proxy .conf files but taking for granted that you have a SSL certificate for your server and sometimes I need to run test locally and connect to a test server, but the test server has no SSL certificate so the connection result on a error.

I've been trying modifying the working reverse proxy configuration. But still not working.

server {
listen 7777 ssl http2;
listen \[::\]:7777 ssl http2;
server_name $mydomain;

    ssl_certificate /etc/letsencrypt/live/xxx.xx.xx/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/xxx.xx.xx/privkey.pem; # managed by Certbot
    
        location / {
            proxy_pass 'http://x.x.x.x:7778';
            proxy_redirect off;
            proxy_read_timeout 7d;
            proxy_send_timeout 7d;
            # Tell upstream the host
            proxy_set_header Host $host;
            # Tell Iupstream real ip & forwarded for header
            proxy_set_header X-Real-IP  $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            # tell upstream this was served via https
            proxy_set_header X-Forwarded-Proto https;
            proxy_buffer_size 2k;
            proxy_buffering off;
            # websocket support
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection $connection_upgrade;
    
            proxy_connect_timeout 10;
        }
    }
0

There are 0 answers