Bitnami Tomcat Version 8.5.16-0 (very old version),如何通过服务器名代理
Bitnami Tomcat Version 8.5.16-0 (very old version), how to proxy by servername
我是 运行 一个非常旧的 bitnami 堆栈(版本 8.5.16-0),但我现在无法更新它。
我需要使用 ServerName
.
将其配置为代理到另一个端口中的另一个服务 运行
我试过了,但没用:
我添加到/opt/bitnami/apache2/conf/bitnami/bitnami-apps-vhosts.conf
:
<VirtualHost *:80>
ServerName sub.mycompany.com
ProxyPreserveHost On
ProxyPass / http://localhost:3001/
ProxyPassReverse / http://localhost:3001/
</VirtualHost>
因此,当我访问 http://mycompany.com
时,我需要它继续访问 tomcat 的默认 AJP 代理配置。但是,当我访问 http://sub.mycompany.com
时,我需要在端口 3001 上代理该自定义服务 运行。
我做错了什么?
嗨,这里是 Bitnami 工程师,
在 /opt/bitnami/apache2/conf/bitnami/bitnami-apps-vhosts.conf
中添加自定义 VirtualHost 是执行此操作的正确方法。我刚刚启动了您正在使用的相同解决方案并将其添加到该文件
<VirtualHost *:80>
ServerName mydomain
RewriteEngine On
RewriteRule ^/(.*) https://www.google.com/ [R,L]
</VirtualHost>
我在端口 3001 中没有服务 运行,但我将 Apache 配置为将连接重定向到 google.com。重启 Apache 后
sudo /opt/bitnami/ctlscript.sh restart apache
我验证了配置是正确的
bitnami@ip-172-31-57-221:/opt/bitnami$ curl -LI 35.168.7.34
HTTP/1.1 200 200
Date: Thu, 20 Aug 2020 08:02:44 GMT
Server: Apache
X-Frame-Options: SAMEORIGIN
Accept-Ranges: bytes
ETag: W/"3660-1499251067000"
Last-Modified: Wed, 05 Jul 2017 10:37:47 GMT
Content-Type: text/html
Content-Length: 3660
bitnami@ip-172-31-57-221:/opt/bitnami$ curl -LI 35.168.7.34.nip.io
HTTP/1.1 302 Found
Date: Thu, 20 Aug 2020 08:02:47 GMT
Server: Apache
X-Frame-Options: SAMEORIGIN
Location: https://www.google.com/
Content-Type: text/html; charset=iso-8859-1
HTTP/1.1 200 OK
Content-Type: text/html; charset=ISO-8859-1
P3P: CP="This is not a P3P policy! See g.co/p3phelp for more info."
Date: Thu, 20 Aug 2020 08:02:47 GMT
Server: gws
X-XSS-Protection: 0
X-Frame-Options: SAMEORIGIN
Transfer-Encoding: chunked
Expires: Thu, 20 Aug 2020 08:02:47 GMT
Cache-Control: private
Set-Cookie: 1P_JAR=2020-08-20-08; expires=Sat, 19-Sep-2020 08:02:47 GMT; path=/; domain=.google.com; Secure
Set-Cookie: NID=204=qoK5Dqh-YCXNgqKmQQVLwHmxmLc7Pa7xoWcPc5iNnb_AqNTdDffYK7dpjoLFalVKEaS-vsKRcNUeJlLkO3GN-jNI4BUGzT0V2--66luMecjNoUWXcriPM8UhX2KtEqFd3Qw2Iu9NE10qeAnvhbDHw34sLDnheaYokmEeUALrSpg; expires=Fri, 19-Feb-2021 08:02:47 GMT; path=/; domain=.google.com; HttpOnly
Alt-Svc: h3-29=":443"; ma=2592000,h3-27=":443"; ma=2592000,h3-T050=":443"; ma=2592000,h3-Q050=":443"; ma=2592000,h3-Q046=":443"; ma=2592000,h3-Q043=":443"; ma=2592000,quic=":443"; ma=2592000; v="46,43"
如您所见,使用自定义 VirtualHost 的请求已重定向到 www.google.com。
为了调试您的问题,我将按照以下步骤操作:
- 检查使用3001端口的服务器是否正常
curl -LI localhost:3001
确保对 sub.mycompany.com
的请求正在使用您的自定义虚拟主机。您需要确保 sub.mycompany.com 未设置为 /opt/bitnami/apache2/conf/httpd.conf
文件中的默认域,并且您也没有在 /opt/bitnami/apache2/conf/bitnami/bitnami.conf
文件中包含该域。您可以尝试使用我上面发布的代码来测试虚拟主机。
记得在对配置应用任何更改后重新启动 Apache
希望这些信息对您有所帮助
我是 运行 一个非常旧的 bitnami 堆栈(版本 8.5.16-0),但我现在无法更新它。
我需要使用 ServerName
.
我试过了,但没用:
我添加到/opt/bitnami/apache2/conf/bitnami/bitnami-apps-vhosts.conf
:
<VirtualHost *:80>
ServerName sub.mycompany.com
ProxyPreserveHost On
ProxyPass / http://localhost:3001/
ProxyPassReverse / http://localhost:3001/
</VirtualHost>
因此,当我访问 http://mycompany.com
时,我需要它继续访问 tomcat 的默认 AJP 代理配置。但是,当我访问 http://sub.mycompany.com
时,我需要在端口 3001 上代理该自定义服务 运行。
我做错了什么?
嗨,这里是 Bitnami 工程师,
在 /opt/bitnami/apache2/conf/bitnami/bitnami-apps-vhosts.conf
中添加自定义 VirtualHost 是执行此操作的正确方法。我刚刚启动了您正在使用的相同解决方案并将其添加到该文件
<VirtualHost *:80>
ServerName mydomain
RewriteEngine On
RewriteRule ^/(.*) https://www.google.com/ [R,L]
</VirtualHost>
我在端口 3001 中没有服务 运行,但我将 Apache 配置为将连接重定向到 google.com。重启 Apache 后
sudo /opt/bitnami/ctlscript.sh restart apache
我验证了配置是正确的
bitnami@ip-172-31-57-221:/opt/bitnami$ curl -LI 35.168.7.34
HTTP/1.1 200 200
Date: Thu, 20 Aug 2020 08:02:44 GMT
Server: Apache
X-Frame-Options: SAMEORIGIN
Accept-Ranges: bytes
ETag: W/"3660-1499251067000"
Last-Modified: Wed, 05 Jul 2017 10:37:47 GMT
Content-Type: text/html
Content-Length: 3660
bitnami@ip-172-31-57-221:/opt/bitnami$ curl -LI 35.168.7.34.nip.io
HTTP/1.1 302 Found
Date: Thu, 20 Aug 2020 08:02:47 GMT
Server: Apache
X-Frame-Options: SAMEORIGIN
Location: https://www.google.com/
Content-Type: text/html; charset=iso-8859-1
HTTP/1.1 200 OK
Content-Type: text/html; charset=ISO-8859-1
P3P: CP="This is not a P3P policy! See g.co/p3phelp for more info."
Date: Thu, 20 Aug 2020 08:02:47 GMT
Server: gws
X-XSS-Protection: 0
X-Frame-Options: SAMEORIGIN
Transfer-Encoding: chunked
Expires: Thu, 20 Aug 2020 08:02:47 GMT
Cache-Control: private
Set-Cookie: 1P_JAR=2020-08-20-08; expires=Sat, 19-Sep-2020 08:02:47 GMT; path=/; domain=.google.com; Secure
Set-Cookie: NID=204=qoK5Dqh-YCXNgqKmQQVLwHmxmLc7Pa7xoWcPc5iNnb_AqNTdDffYK7dpjoLFalVKEaS-vsKRcNUeJlLkO3GN-jNI4BUGzT0V2--66luMecjNoUWXcriPM8UhX2KtEqFd3Qw2Iu9NE10qeAnvhbDHw34sLDnheaYokmEeUALrSpg; expires=Fri, 19-Feb-2021 08:02:47 GMT; path=/; domain=.google.com; HttpOnly
Alt-Svc: h3-29=":443"; ma=2592000,h3-27=":443"; ma=2592000,h3-T050=":443"; ma=2592000,h3-Q050=":443"; ma=2592000,h3-Q046=":443"; ma=2592000,h3-Q043=":443"; ma=2592000,quic=":443"; ma=2592000; v="46,43"
如您所见,使用自定义 VirtualHost 的请求已重定向到 www.google.com。
为了调试您的问题,我将按照以下步骤操作:
- 检查使用3001端口的服务器是否正常
curl -LI localhost:3001
确保对
sub.mycompany.com
的请求正在使用您的自定义虚拟主机。您需要确保 sub.mycompany.com 未设置为/opt/bitnami/apache2/conf/httpd.conf
文件中的默认域,并且您也没有在/opt/bitnami/apache2/conf/bitnami/bitnami.conf
文件中包含该域。您可以尝试使用我上面发布的代码来测试虚拟主机。记得在对配置应用任何更改后重新启动 Apache
希望这些信息对您有所帮助