Score:1

Replicate nginx reverse proxy config using apache

in flag

nginx config:

server {
    listen 443 ssl http2;
    listen [::]:443 ssl http2;
    ssl_certificate /path/to/tls/tls.crt;
    ssl_certificate_key /path/to/tls/tls.key;
    
    server_name the.domain.tld;
    
    location / {
        proxy_pass http://localhost:5001; 
    }

    location /api/socket {
        proxy_pass http://localhost:5001/api/socket;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "Upgrade";
        proxy_set_header Host $host;
    }
    
}

apache config:

<VirtualHost *:443>
        ServerName the.domain.tld

        ProxyPass / http://localhost:5001/
        ProxyPassReverse / http://localhost:5001/
        ProxyPass /api/socket http://localhost:5001/api/socket/
        ProxyPassReverse /api/socket http://localhost:5001/api/socket/

        RewriteEngine on

        RewriteCond %{HTTP:Upgrade} websocket [NC]
        RewriteCond %{HTTP:Connection} upgrade [NC]
        RewriteRule /(.*) "ws://localhost:5001/$1" [P,L]

        ProxyPreserveHost On
        ProxyAddHeaders On
        RequestHeader set X-Forwarded-Proto "https"

        SSLCertificateFile /path/to/tls/tls.crt
        SSLCertificateKeyFile /path/to/tls/tls.key

        SSLProxyEngine On
</VirtualHost>
Michael Hampton avatar
cz flag
What is the problem you are having?
in flag
The website redirection works if I'm using nginx reverse proxy. However, when I switch to apache2, the website doesn't redirect me.
Michael Hampton avatar
cz flag
Huh? I don't see any redirects in either configuration. Did you omit some part of the configuration, or are you talking about something else?
in flag
I'm following this guide on GitHub. However, I can't find a guide on apache reverse proxy config. https://github.com/varbhat/exatorrent/blob/main/docs/deploy.md#reverse-proxy
djdomi avatar
za flag
wh, do you want to switch? Use nginx in front off and use apache in the background. it is a common used practice
Score:1
in flag

Solved! All I had to do was to enable the websocket module using sudo a2enmod proxy_wstunnel.

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.