FAQ. Reverse Proxy

Материал из WiKi - UserSide

en | ru

You can use a reverse proxy in front of USERSIDE. To do this, you need to specify the IP address of your proxy (or subnet) on the USERSIDE side. That is, the address that USERSIDE will see when accessed from this proxy.

For example, if you have a reverse proxy that accepts connections at 198.51.100.25, and proxies requests to USERSIDE on the 192.168.10.0/24 network, then you must specify either the IP address of the host with the proxy from the 192.168.10.0/24 network.

To do this, you must add the following environment variable to the /var/www/userside/.env file, the value of which can be an IP address, a subnet, or a comma-separated list of addresses and subnets. For example:

US_REVERSE_PROXY_TRUSTED_HOSTS=192.168.10.1

Configuring Nginx as a reverse proxy

What follows is a basic example of configuring nginx as a reverse proxy server (192.168.10.2 is the address of the intended userside host):

server {
    listen 80;

    location / {
        proxy_pass  http://192.168.10.2/;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_send_timeout 300;
        proxy_read_timeout 300;
    }

    location /ws {
        proxy_pass http://192.168.10.2:15674/ws;
        proxy_http_version 1.1;
        proxy_set_header Host $host;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "Upgrade";
    }
}