[英]How to configure Apache reverse proxy domain url to specific url on localhost
我遇到了配置apache反向代理服務器時遇到的問題。 我想使用一個URL eq .: https://software.testsite.net ,我的反向代理應該使用http:// localhost:82 / customapp進行配置。
當前的問題,當我導航到https://www.testsite.net時,它被替換為http:// localhost:82 / customapp 。
我該如何配置呢? 我的配置:
<VirtualHost *:443>
SSLEngine on
ServerName software.testsite.net
SSLProxyEngine On
SSLCertificateFile "${SRVROOT}/certs/testsite.crt"
SSLCertificateKeyFile "${SRVROOT}/certs/testsite.key"
SSLCertificateChainFile "${SRVROOT}/certs/testsite.ca-bundle"
RequestHeader edit Destination ^https http early
<Location />
RedirectMatch ^/$ https://localhost:82/customapp
ProxyPass http://localhost:82/customapp
ProxyPassReverse http://localhost:82/customapp
</Location>
</virtualhost>
<VirtualHost *:80>
ProxyPreserveHost On
ProxyVia on
RewriteEngine on
ProxyRequests Off
SSLProxyEngine On
SSLCertificateFile "${SRVROOT}/certs/testsite.crt"
SSLCertificateKeyFile "${SRVROOT}/certs/testsite.key"
SSLCertificateChainFile "${SRVROOT}/certs/testsite.ca-bundle"
# used for enforcing http to https
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{SERVER_NAME}$1 [R,L]
ServerName software.testsite.net
<Location />
ProxyPass http://localhost:82/customapp
ProxyPassReverse http://localhost:82/customapp
</Location>
</VirtualHost>
我終於讓它工作了。 不知道這是否是應該完成的方式。
<VirtualHost *:80>
ServerName software.testsite.net
DocumentRoot "${SRVROOT}/htdocs/software"
DirectoryIndex index.html
ProxyPreserveHost On
ProxyVia on
RewriteEngine on
ProxyRequests Off
# used for enforcing http to https
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{SERVER_NAME}$1 [R,L]
SSLProxyEngine On
SSLCertificateFile "${SRVROOT}/certs/testsite.crt"
SSLCertificateKeyFile "${SRVROOT}/certs/testsite.key"
SSLCertificateChainFile "${SRVROOT}/certs/testsite.ca-bundle"
<Location /customapp>
ProxyPass http://localhost:82/customapp
ProxyPassReverse http://localhost:82/customapp
</Location>
</VirtualHost>
<VirtualHost *:443>
ServerName software.testsite.net
DocumentRoot "${SRVROOT}/htdocs/software"
DirectoryIndex index.html
RequestHeader edit Destination ^https http early
SSLEngine on
SSLProxyEngine On
SSLCertificateFile "${SRVROOT}/certs/testsite.crt"
SSLCertificateKeyFile "${SRVROOT}/certs/testsite.key"
SSLCertificateChainFile "${SRVROOT}/certs/testsite.ca-bundle"
<Location /customapp>
RedirectMatch ^/$ https://localhost:82/customapp
ProxyPass http://localhost:82/customapp
ProxyPassReverse http://localhost:82/customapp
</Location>
</virtualhost>
<!DOCTYPE html>
<html>
<head>
<title>HTML Meta Tag</title>
<meta http-equiv = "refresh" content = "1; url =http://software.testsite.net/customapp"/>
</head>
<body>
<p>Redirecting...</p>
</body>
</html>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.