💡

Proxmox VEの管理コンソールのポートを443にリダイレクトする方法

2025/03/12に公開

前書き

基本的には以下の公式の手順に従ってやれば出来ますが途中で詰まったのでやり方を書いておきます。
大体が公式の手順の引用です。
https://pve.proxmox.com/wiki/Web_Interface_Via_Nginx_Proxy

手順

1. nginxをインストールする

apt install nginx

2. nginxデフォルトのコンフィグを削除する

rm /etc/nginx/sites-enabled/default

3. nginxのコンフィグの作成

/etc/nginx/conf.d/proxmox.confにお好みのテキストエディタで下記を記載してください。

/etc/nginx/conf.d/proxmox.conf
upstream proxmox {
    server "[ここにFQDNを入れる]";
}
 
server {
    listen 80 default_server;
    listen [::]:80 default_server;
    rewrite ^(.*) https://$host$1 permanent;
}
 
server {
    listen 443 ssl;
    listen [::]:443 ssl;
    server_name _;
    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;
    }
}

書き込めたら以下のコマンドを実行し、正しく設定できているか確認します。

nginx -t

実行すると正しく設定できていれば以下のようなものが表示されると思います。

nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

4. nginxを再起動する

systemctl restart nginx

これで443ポートでアクセス出来るようになっていると思います。

5. 起動時に自動でnginxを実行するようにする

証明書が利用可能になった後にnginxを起動するようにします。

systemctl edit nginx.service

恐らく8行目に書かれている### Lines below this comment will be discardedよりも上に下記を記載してください。

/etc/systemd/system/nginx.service.d/override.conf
[Unit]
Requires=pve-cluster.service
After=pve-cluster.service

以上で443ポートで管理コンソールにアクセス出来るようになっていると思います。

Discussion