一个 apache-http-server 在同一台 Linux 机器上为三个 tomcat 实例提供服务

一个 apache-http-server 在同一台 Linux 机器上为三个 tomcat 实例提供服务

我正在尝试通过一个 apache-http-server 在同一台 Linux 机器上为三个 tomcat 实例提供服务。tomcat 上的 App1 监听 8080,App2 监听 8081,App3 监听 8082。应该有三个网站可以访问它们。对于 App1,website.domain.com/App1。对于 App2,website.domain.com/App2。对于 App3,website.domain.com/App3。

现在,vhosts.conf 看起来如下所示。我认为它有点混乱。它无法正常工作。你能帮我解决这个问题吗?

[root@servername conf.d]# 更多vhosts.conf

<VirtualHost *:80>
ServerName website.domain.com/App1

ProxyRequests On
    ProxyPass / http:// localhost:8081/App1/
    ProxyPassReverse / http:// localhost:8081/App1/
</VirtualHost>

<VirtualHost *:80>
ServerName website.domain.com/App2

ProxyRequests On
    ProxyPass / http://localhost:8081/App2/
    ProxyPassReverse / http://localhost:8081/App2/
</VirtualHost>

<VirtualHost *:80>
ServerName website.domain.com/App2

ProxyRequests On
    ProxyPass / http:// localhost:8082/App2/
    ProxyPassReverse / http:// localhost:8082/App2/
</VirtualHost>


<VirtualHost *:80>
  RewriteEngine on
  RewriteRule (.*) https://%{HTTP_HOST}$1
</VirtualHost>

<VirtualHost *:443>
  SSLEngine on
  ServerName %{HTTP_HOST}
  ServerAlias *.domain.com

  Header always set Strict-Transport-Security "max-age=63072000;"
  Header always set X-Frame-Options DENY
  Header edit Set-Cookie ^(.*)$ $1;HttpOnly;Secure
  RequestHeader set X-Forwarded-Proto https
  RequestHeader set Front-End-Https "On"

  LogLevel warn
  ErrorLog logs/ssl_error_log
  TransferLog logs/ssl_access_log
  CustomLog logs/ssl_request_log "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"

  ProxyPassReverseCookieDomain localhost %{HTTP_HOST}
  ProxyPreserveHost On
  #ProxyRequests off
  RequestHeader unset Origin

  ProxyPass / http:// localhost:8080/

  ProxyPassReverse / http:// localhost:8080/
  ProxyPass / http:// localhost:8081/
  ProxyPassReverse /  http://localhost:8081/
  ProxyPass / http:// localhost:8082/
  ProxyPassReverse / http:// localhost:8082/

答案1

服务器名是域名,而不是 URL。

对于端口 80,您只需要 1 个虚拟主机块和 3 对 Proxypass 和 ProxypassRevetse 规则。

规则的格式应包含如下路径:

  ProxyPass /app1 http://localhost:8082/
  ProxyPassReverse /app1 http://localhost:8082/

相关内容