Use Nginx proxypass to specific user and make it persistent

chrismfz

Verified User
Joined
Jul 3, 2019
Messages
34
I am planning to use Nginx as a REVERSE PROXY for only one user + load balancing something like:

upstream cluster {
ip_hash;
server x.x.x.x:443 weight=10;
server x.x.x.x:443 weight=20;
}

server {
listen 80 default_server;
listen [::]:80 default_server;
server_name user-domain-goes-here;

location / {
proxy_pass http://cluster/;
}

}



I know I can use something like
cd /usr/local/directadmin/data/templates/custom/
cp -p ../nginx_server.conf .
cp -p ../nginx_server_secure.conf .
But I would like to know if there a way to edit only the specific user's configuration and make it persist not only when updating but even
if I move/transfer the user to another server.

I can also make another conf, like nginx-custom.conf but then I couldn't have let's encrypt I assume.

So I am looking how can I possible integrate this in the user's conf, make it have let's encrypt, persist, and if I move the user to another server it will be there too.
 
This's just sample,
Before do this, ennsure you move all contents of your select website to other location from current server, php code might expose to around the world.

it possible without custom full template. this can done via "Custom HTTPD Configurations"

disable default template location
#[CUSTOM] block
Code:
|?HAVE_NGINX_PROXY=0|
Before do next step, save and recheck the location block of user virtualhost should gone aways.


then add your own location block at CUSTOM3

#[CUSTOM3] block
Code:
location /
    {
|CUSTOM2|
        # access_log off;
        proxy_buffering |PROXY_BUFFERING|;
        proxy_pass http://cluster/;
        proxy_set_header X-Client-IP      $remote_addr;
        proxy_set_header X-Accel-Internal /nginx_static_files;
        proxy_set_header Host             $host;
        proxy_set_header X-Forwarded-For  $proxy_add_x_forwarded_for;
        proxy_hide_header Upgrade;
    }
    location /nginx_static_files/
    {
        # access_log  /var/log/nginx/access_log_proxy;
        alias       "|DOCROOT|/";
        internal;
    }
and save

Something like this.
 
Back
Top