0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Proxmox VEで管理コンソールのポートを8006から443に変えるオススメの方法

Posted at

変える、と言いましたが正確には8006/443の両方からアクセス可能です。ごめんなさい。

下記の方法が有名ですが、関連付けされたNICのポート全てにNATされておかしくなります。

これはオススメしません
/sbin/iptables -F
/sbin/iptables -t nat -F
/sbin/iptables -t nat -A PREROUTING -p tcp --dport 443 -j REDIRECT --to-port 8006

この場合443ポートにアクセスすると正しく管理コンソールにアクセスできます。
しかし、管理画面のNICに関連するブリッジは、どの仮想マシンに割り当てたIPアドレスからでも443ポートのアクセスがProxmoxホストにリダイレクトされます。

vmbr0にCIDR/GWが割り当てられている場合、それらに関連するVMのすべての443ポートへのアクセスはProxmoxホストの管理画面へリダイレクトされます。

最悪の場合、内部にもう1つネットワークを作成してVMを配置すると、どのhttpsサイトにアクセスしても管理画面へリダイレクトされる現象が発生します。

つまり、管理用のNICとVM用のNICを分けていない場合、上記の方法は推奨されません。

基本的にはnginxでリバースプロキシを配置する下記の方法がオススメです。

/etc/nginx/sites-enabled/default
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}

server {
        listen 80;
        listen [::]:80;
        server_name _;
        location / {
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection $connection_upgrade;
        proxy_pass https://127.0.0.1:8006/;
        proxy_buffering off;
        client_max_body_size 0;
        proxy_read_timeout 3600s;
        proxy_send_timeout 3600s;
        send_timeout 3600s;
        }
}

server {
        listen 443;
        listen [::]:443;
        ssl on;
        ssl_certificate /etc/pve/local/pveproxy-ssl.pem;
        ssl_certificate_key /etc/pve/local/pveproxy-ssl.key;
        server_name _;
        location / {
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection $connection_upgrade;
        proxy_pass https://127.0.0.1:8006/;
        proxy_buffering off;
        client_max_body_size 0;
        proxy_read_timeout 3600s;
        proxy_send_timeout 3600s;
        send_timeout 3600s;
        }
}

HTTPはCloudflare Zero Trustでトンネル張る用で開いています。
HTTPSの証明書は各ノードのシステム→証明書より、ACMEなりオレオレ証明書なりを登録すると使用できます。
必要に応じて設定はいい感じに弄ってください。

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?