ksassnowski / utgars-chronicles.app

Source code of https://utgars-chronicles.app, a free web app to help you play Microscope online.
https://utgars-chronicles.app
MIT License
35 stars 9 forks source link

Page not refreshing behind Apache2 reverse proxy #26

Open jason-weiser opened 2 years ago

jason-weiser commented 2 years ago

First off, just want to say that this is such an awesome app. Thank you so much for making it.

I know this isn't an issue, just plain user error or ignorance on my part, but no amount of searching has helped me find the right way to set this up behind an Apache2 reverse proxy. I'm extremely grateful for any help you can provide or even just pointing me in the right direction.

Basically, after setting up the app according to the README, here are two different Apache2 configs that I've tried:

<VirtualHost :443> ServerName mydomain.com ProxyPreserveHost On ProxyPass / http://127.0.0.1:8000/ ProxyPassReverse / http://127.0.0.1:8000/ SSLEngine on SSLCertificateFile /something/something/fullchain.cer SSLCertificateKeyFile /something/something.key ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined <VirtualHost :80> ServerName mydomain.com RewriteEngine on RewriteCond %{SERVER_NAME} =mydomain.com RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]

This one won't move past the login page for some reason? It seems to think I'm not using https on the form submission despite the page appearing to have a valid certificate in the address bar.

<VirtualHost :443> ServerName mydomain.com SSLEngine on SSLCertificateFile /something/something/fullchain.cer SSLCertificateKeyFile /something/something.key DocumentRoot /var/www/utgar/public <Directory /var/www/utgar/public> AllowOverride All ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined <VirtualHost :80> ServerName mydomain.com RewriteEngine on RewriteCond %{SERVER_NAME} =mydomain.com RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]

This one works almost perfectly, but won't update the game page with new periods/events/scenes unless the page is refreshed.

Once again, thanks for any help.

EDIT: for some reason it edited out the closing tags for the Apache virtual host files but they do exist

wushepeng commented 2 years ago

You need websocket config, something like :

<IfModule mod_proxy_wstunnel.c>
  RewriteEngine On
  RewriteCond %{REQUEST_URI}  ^/(.*)            [NC]
  RewriteCond %{HTTP:Upgrade} =websocket [NC]
  RewriteRule /(.*)           ws://mondomaine.example.com:6001/$1 [P,L]
</IfModule>
athshean commented 2 years ago

I'm having the same issue with the app not refreshing behind an Nginx reverse proxy. I've set up a websocket config on nginx as follows:

server {

    server_name mu_domain;

    include certbot-challenge.conf;
    include ssl.conf;

    listen 443 ssl http2;
    listen [::]:443 ssl http2;

    location / {
        proxy_set_header Host $http_host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For 
        $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
        proxy_http_version 1.1;
        proxy_pass http://utgars:8000;
    }
}

The utgars app is running in a Docker container.

Is there anything I'm missing with the websocket configurations?