AttorneyOnline / webAO

Attorney Online Web Client
http://web.aceattorneyonline.com
GNU Affero General Public License v3.0
20 stars 13 forks source link

Fix https issue once and for all #218

Open OmniTroid opened 8 months ago

OmniTroid commented 8 months ago

As we know, one of the most reported issues in webAO remains the "please remove the s from https" error, which occurs when https and ws (insecure websocket) is used on web.aceattorneyonline.com. This is a quite serious usability issue, and many browsers make it hard to modify the http protocol in the address bar.

In order to fix this properly and robustly, webAO needs to be hosted on a proper, configurable webserver (not github pages). Assuming an ssh key is set up correctly on the machine, this deployment is very simple using rsync: npm run build && rsync -av --delete dist/ server:/var/www/webao/

Furthermore, nginx can be configured as follows to always instruct the client correctly in terms of protocols:

server {
        listen 80;
        server_name web.aceattorneyonline.com;

        location / {
                # If the client is connecting on http and with wss, upgrade to https
                if ($arg_connect ~* (wss:)) {
                        return 302 https://$host$request_uri;
                }

                root /var/www/webao;
                index index.html;
        }
}

server {
        listen 443 ssl;
        server_name web.aceattorneyonline.com;

        ssl_certificate /var/cert/web.aceattorneyonline.com/fullchain.pem;
        ssl_certificate_key /var/cert/web.aceattorneyonline.com/privkey.pem;

        location / {
                # If the client is connecting on https and with ws, downgrade to http
                if ($arg_connect ~* (ws:)) {
                        return 302 http://$host$request_uri;
                }

                root /var/www/webao;
                index index.html;
        }
}

It should be quite straightforward to configure this behind a CDN (eg. cloudflare) as well.