2 Nginx Virtual Servers on one physical server behind HAPROXY



  • If you take a look at these to sites you will see my issue,

    https://blog.ahmza.com
    https://shop.ahmza.com

    I have setup two virtual nginx servers on ubuntu 20.04 server and I have HAproxy setup on my pFsense firewall

    Here is the nginx config for the shop sub domain

    server {
        listen 80;
        listen [::]:80;
    
        server_name shop.ahmza.com;
        root /var/www/shop;
    
        location / {
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header Host $http_host;
            proxy_pass http://127.0.0.1:2368;
    
        }
    
        location ~ /.well-known {
            allow all;
        }
    
        client_max_body_size 50m;
    }
    

    Here is the nginx config for the blog sub domain

    server {
        listen 80;
        listen [::]:80;
    
        server_name blog.ahmza.com;
        root /var/www/ghost/system/nginx-root;
    
        location / {
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header Host $http_host;
            proxy_pass http://127.0.0.1:2368;
    
        }
    
        location ~ /.well-known {
            allow all;
        }
    
        client_max_body_size 50m;
    }
    

    I cant see the problem here because they have separated root folders, i think its to do with the proxy stuff but i cant figure it out


Log in to reply