Difference between revisions of "Web Interface Via Nginx Proxy"

From Proxmox VE
Jump to navigation Jump to search
Line 2: Line 2:
 
This allows you to access Proxmox VE via the port 443
 
This allows you to access Proxmox VE via the port 443
  
''Tested from Proxmox 3.4 - 5.1''
+
''Tested from Proxmox 3.4 - 6.1''
  
 
'''Why do I need this?'''
 
'''Why do I need this?'''

Revision as of 15:02, 16 March 2020

Introduction

This allows you to access Proxmox VE via the port 443

Tested from Proxmox 3.4 - 6.1

Why do I need this?

Sometimes there is a firewall restriction that blocks port 8006 and since we shouldn't touch the port config in proxmox we'll just use nginx as proxy to provide the web interface available on default https port 443. Now let's begin...

Configuration

  • install nginx
apt install nginx
  • remove the default config file – not needed on PVE 4/5 (Stretch & Jessie!)
rm /etc/nginx/conf.d/default

respectively

rm /etc/nginx/sites-enabled/default
  • create a new config file
nano /etc/nginx/conf.d/proxmox.conf

Note: You can choose the configuration filename freely, but it must have a .conf ending.

The following is an example config that works for the web interface and also the noVNC console:

upstream proxmox {
    server "FQDN HOSTNAME";
}
 
server {
    listen 80 default_server;
    rewrite ^(.*) https://$host$1 permanent;
}
 
server {
    listen 443;
    server_name _;
    ssl on;
    ssl_certificate /etc/pve/local/pve-ssl.pem;
    ssl_certificate_key /etc/pve/local/pve-ssl.key;
    proxy_redirect off;
    location / {
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade"; 
        proxy_pass https://localhost:8006;
	proxy_buffering off;
	client_max_body_size 0;
	proxy_connect_timeout  3600s;
        proxy_read_timeout  3600s;
        proxy_send_timeout  3600s;
        send_timeout  3600s;
    }
}
  • Test and Apply new config
 nginx -t  # checks config syntax
 systemctl restart nginx
  • ensure that nginx gets only started after the certificates are available

As the certificates reside on /etc/pve which is provided by the pve-cluster.service we need to tell nginx.service to only start after that one. The easiest and cleanest way to do that is to add an Requires and After as systemd override snippet.

This can be done with systemd edit UNIT which opens your $EDITOR:

  # systemctl edit nginx.service

here add:

[Unit]
Requires=pve-cluster.service
After=pve-cluster.service

and save + exit.

Enjoy the webinterface on HTTPS port 443!

See Also

NoVNC reverse Proxy with Apache https://forum.proxmox.com/threads/working-novnc-with-reverse-proxy-on-5-1.43644/