Reverse Proxy using Subdirectory

xeroiv

Active Member
May 19, 2018
6
0
41
41
Hi,

I can't get my reverse proxy to work right in order to access Proxmox via mydomain / proxmox. I believe that I am fairly close to getting it to work as the index of the page loads as well as some other peices of the webpage. The configuration that I based my proxy can be found on a 2015 blogspot by xorthings but it appears to be for version 4 of proxmox and does not work with the version I have installed (5.1).

However proxmoxlib.js?ver=1.0-18 gives a 404 not found as it tries to load my domain / proxmoxlibjs?ver=1.0-18 when it should actually be loading my domain / proxmox / proxmoxlib.js?ver=1.0-18. I think this wouldnt be a problem if the index file didn't use a leading slash for the script reference but I dont know where that is kept on the pve host. Can anyone here help me correct my Nginx configuration to get this reverse proxy setup working?

Nginx configuration:
Code:
upstream proxmox {
    server "mydomain";
}

server {
    listen 80 default_server;
    rewrite ^(.*) http(s) : //$host$1 permanent;
}

server {
    listen 443;
    server_name _;
    ssl on;
    ssl_certificate /etc/letsencrypt/live/mydomain/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/mydomain/privkey.pem; # managed by Certbot
  location ~* ^/(?:proxmox|pve2|api2|novnc)$ {
    rewrite /(proxmox|pve2|api2|novnc) /$1/ permanent;
  }
  location ~* ^/(?:proxmox|pve2|api2|novnc)/ {
    rewrite /proxmox/(.*) /$1 break;
    rewrite /((?:pve2|api2|novnc)/.*) /$1 break;
    proxy_pass http(s) : //192.168.X.X:8006;
    proxy_read_timeout 90;
    proxy_redirect off;
    proxy_http_version 1.1;
    proxy_set_header Connection "upgrade";
    proxy_set_header Origin http : //$host;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Host $host;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto $scheme;
    add_header X-Frame-Options SAMEORIGIN;
  }
}
 
I also tried it back in 2017 and I was not able to do it. I ended up using a virtual host without any directory remapping. It worked straight away.
 
I also tried a reverse proxy via a sub-directory with apache and couldn't get it to work. Similar to LnxBil, I managed to get it working without any modifications with a new virtual host instead.
 
I've just been trying to do same.
Has anyone got this to work (with Nginx)?
I was also trying to do with Haproxy, but without success
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!