我已经安装了 Apache/2.4.56 (Debian)、noip URL 和几个 LXC 容器。我需要访问 LXC 容器内的 Web 应用程序:
example.com/app1 -> LXC container 1 (with Zend2)
example.com/app2 -> LXC container 2 (with Laravel 5)
example.com/app3 -> LXC container 3 (with Mattermost)
example.com/app4 -> LXC container 4 (with Plex)
example.com/app5 -> LXC container 5 (with Laravel 10)
example.com/app6 -> LXC container 5 (with Psono)
...
example.com/appN -> LXC container N
IP1:10.0.3.101
IP2:10.0.3.102
域名网址:http://example.com
第一种方法:
<VirtualHost *:80>
ProxyPreserveHost On
ProxyPass "/app1" "http://ip1"
ProxyPassReverse "/app1" "http://ip1"
</VirtualHost>
如果我输入example.com/app1
这个,它会将我发送到example.com/auth/index/index
(我输了app1
,这应该是example.com/app1/auth/index/index
)。ProxyPassReverse 不起作用?
第二种方法:
<VirtualHost *:80>
ProxyPreserveHost On
ProxyPass "/app1" "http://ip1"
ProxyPassReverse "/app1" "http://ip1"
ProxyPassReverse "/app1" "/"
</VirtualHost>
这效果很好!但我需要更多 LXC 容器。
第三种方法:
<VirtualHost *:80>
ProxyPreserveHost On
ProxyPass "/app1" "http://ip1"
ProxyPassReverse "/app1" "http://ip1"
ProxyPassReverse "/app1" "/"
ProxyPass "/app2" "http://ip2"
ProxyPassReverse "/app2" "http://ip2"
</VirtualHost>
example.com/app1
-> 确定
按钮是错误的,所以我做了一些更改:按钮的原始操作是
action="{{ route('login') }}"
,它解析为domain_url/login
所以我将其更改为
action="domain_url/app2/login">
,结果是:
example.com/app2
-> 欢迎页面 -> example.com/app2/login
(登录页面)->example.com/app1/app2/login
错误
第四种方法:
<VirtualHost *:80>
ProxyPreserveHost On
ProxyPass "/app1" "http://ip1"
ProxyPassReverse "/app1" "http://ip1"
## WITH OUT THIS ##ProxyPassReverse "/app1" "/"
ProxyPass "/app2" "http://ip2"
ProxyPassReverse "/app2" "http://ip2"
</VirtualHost>
example.com/app1
->example.com/auth/index/index
错误
按钮是错误的,所以我做了一些更改:按钮的原始操作是
action="{{ route('login') }}"
,它解析为domain_url/login
所以我将其更改为
action="domain_url/app2/login">
,结果是:
example.com/app2
-> 欢迎页面 -> example.com/app2/login
(登录页面)->```example.com/app2/# 丢失了许多 css、js 和图像。
我认为我不必使用 ProxyPassReverse“/app1”“/” , so I continue that path but always got
example.com/app1 ->
example.com/auth/index/index```
这种方法是:
<VirtualHost *:80>
ProxyPreserveHost On
ProxyPass "/app1" "http://ip1"
ProxyPassReverse "/app1" "http://ip1"
ProxyPass "/app2" "http://ip2"
ProxyPassReverse "/app2" "http://ip2"
##HERE THE ATTEMPS .. serverfault do not like to spam the same text over and over again xD
</VirtualHost>
尝试:
Attempt #1
RewriteEngine On
RewriteCond %{HTTP_HOST} ^10\.0\.3\.101$
RewriteRule ^/(.*)$ domain_url/app1/$1 [P,L]
RewriteCond %{HTTP_HOST} ^10\.0\.3\.102$
RewriteRule ^/(.*)$ domain_url/app2/$1 [P,L]
Attempt #2
RewriteEngine On
RewriteCond %{RESPONSE} ^.*app1.*
RewriteRule ^/app1/(.*)$ /app1/$1 [P,L]
RewriteCond %{RESPONSE} ^.*app2.*
RewriteRule ^/app2/(.*)$ /app2/$1 [P,L]
Attempt #3
RewriteEngine On
RewriteCond %{REQUEST_URI} ^/app1/
RewriteRule ^/app1/(.*)$ domain_url/app1/$1 [P,L]
RewriteCond %{REQUEST_URI} ^/app2/
RewriteRule ^/app2/(.*)$ domain_url/app2/$1 [P,L]
Attempt #4
ProxyHTMLEnable On
ProxyHTMLExtended On
ProxyHTMLURLMap http://ip1 domain_url/app1
ProxyHTMLURLMap http://ip2 domain_url/app2
Attempt #5
AddOutputFilterByType SUBSTITUTE text/html
Substitute "s|http://10\.0\.3\.101|domain_url/app1|n"
Substitute "s|http://10\.0\.3\.102|domain_url/app2|n"
Attempt #6
RequestHeader edit Location ^http://10\.0\.3\.101(.*)$ domain_url/app1$1
RequestHeader edit Location ^http://10\.0\.3\.101(.*)$ domain_url/app2$1
我需要更多想法来测试,有人能帮我吗?拜托,欢迎任何想法。非常感谢你的帮助。如果这有效,那么我想配置 HTTPS :D
/app1
PS:我不喜欢使用ports,使用等更正式。