我在http://localhost:8888/
上运行了localhost服务
下面的Apache配置向http://myapp.example.com发出任何请求,无论是http还是https,以使用HTTPS并充当反向代理。
<VirtualHost *:80>
ServerName myapp.example.com
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{SERVER_NAME}/$1 [R,L]
</VirtualHost>
<VirtualHost *:443>
ServerName myapp.example.com
SSLEngine on
SSLCipherSuite EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH
SSLProtocol All -SSLv2 -SSLv3 -TLSv1 -TLSv1.1
SSLHonorCipherOrder On
SSLCertificateFile /etc/letsencrypt/live/myapp.example.com/cert.pem
SSLCertificateKeyFile /etc/letsencrypt/live/myapp.example.com/privkey.pem
SSLCertificateChainFile /etc/letsencrypt/live/myapp.example.com/chain.pem
<Location />
ProxyPass http://localhost:8888/
ProxyPassReverse http://localhost:8888/
</Location>
</VirtualHost>
但是,我想要以下代理模式:
http://myapp.example.com/app1 --> http://localhost:8888/
http://myapp.example.com/app1/ --> http://localhost:8888/
https://myapp.example.com/app1 --> http://localhost:8888/
https://myapp.example.com/app1/ --> http://localhost:8888/
http://myapp.example.com/app2 --> http://localhost:8889/
http://myapp.example.com/app2/ --> http://localhost:8889/
https://myapp.example.com/app2 --> http://localhost:8889/
https://myapp.example.com/app2/ --> http://localhost:8889/
始终确保HTTPS到位。
我尝试过类似的模式但没有成功:
ProxyPreserveHost On
RewriteEngine On
RewriteRule ^/appX/(.*) http://x.x.x.x:8000/$1 [P,L]
ProxyPassReverse /appX/ http://x.x.x.x:8000/
有人可以帮助我确定配置文件中应更改的内容吗?
服务器版本:Apache / 2.4.6(CentOS) CentOS 7