portainer with Apache2 as reverse proxy
warning:
这篇文章距离上次修改已过1477天,其中的内容可能已经有所变动。
作为更目录在apache配置文件里面加入以下配置
# Proxy to Portainer
ProxyPreserveHost On
ProxyPass / http://127.0.0.1:9000/
ProxyPassReverse / http://127.0.0.1:9000/
RequestHeader set X-Forwarded-Proto "https"
ProxyVia Block
<Proxy *>
Require all granted
</Proxy>
<Location /api/websocket/>
RewriteEngine on
RewriteCond %{HTTP:UPGRADE} ^WebSocket$ [NC]
RewriteCond %{HTTP:CONNECTION} Upgrade$ [NC]
RewriteRule /api/websocket/(.*) ws://127.0.0.1:7900/api/websocket/$1 [P]
</Location>
作为网站的子目录
<Location /portainer/>
ProxyPass http://127.0.0.1:9000/
ProxyPassReverse http://127.0.0.1:9000/
RequestHeader set X-Forwarded-Proto "https"
</Location>
<Location /portainer/api/websocket/>
ProxyPass http://127.0.0.1:9000/api/websocket/
ProxyPassReverse http://127.0.0.1:9000/api/websocket/
RewriteEngine on
RewriteCond %{HTTP:UPGRADE} ^WebSocket$ [NC]
RewriteCond %{HTTP:CONNECTION} Upgrade$ [NC]
RewriteRule /api/websocket/(.*) ws://127.0.0.1:9000/api/websocket/$1 [P]
</Location>