HTTPS 到 HTTP 的 Apache 反向代理
Apache reverse proxy for HTTPS to HTTP
我正在尝试设置反向代理以将 https 请求重定向到 HTTP URL。我有一个 java 应用程序,它启动 tomcat 并在那个 tomcat 实例上托管一些服务。
另一个应用程序将使用 https 调用这些服务,这应该重定向到 http url。下面是我做的代理配置。
在 httpd.conf 中启用了 mod_ssl.so、mod_proxy.so 和 mod_proxy_http.so 模块。并且还在 IFModule 下面添加到同一文件。
<IfModule ssl_module>
Listen 443
</IfModule>
以下是 vhosts.conf 文件的内容。
<VirtualHost *:443>
ServerName domain.name.com
ServerAdmin admin@domain.com
DocumentRoot C:/Apache24/htdocs
# ErrorLog ${APACHE_LOG_DIR}/error.log
# CustomLog ${APACHE_LOG_DIR}/access.log combined
SSLEngine On
SSLCertificateFile /certificate_path
SSLCertificateKeyFile /privatekey_path
SSLCertificateChainFile /chain_cert_path
AllowEncodedSlashes NoDecode
RequestHeader set X-Forwarded-Proto "https"
RequestHeader set X-Forwarded-Port "443"
ProxyRequests Off
<Proxy *>
AddDefaultCharset Off
Order deny,allow
Allow from all
</Proxy>
RedirectMatch ^/metadata-agent$ /metadata-agent/
ProxyPass /metadata-agent/ http://localhost:8084/ nocanon
ProxyPassReverse /metadata-agent/ http://localhost:8084/
RedirectMatch ^/tdv$ /tdv/
ProxyPass /tdv/ http://localhost:9400/ nocanon
ProxyPassReverse /tdv/ http://localhost:9400/
ProxyErrorOverride Off
ProxyPassReverseCookieDomain domain.name.com localhost
ProxyPassReverseCookiePath / /
ProxyPreserveHost on
SSLProxyEngine On
SSLProxyCheckPeerCN off
SSLProxyCheckPeerExpire off
</VirtualHost>
我已经尝试了 SOF 中所有可能的答案。但没有任何效果。我收到以下回复 URL:
http://localhost:8084/tdv-soap/datasource/all
当我将其替换为 https://domain.name.com/tdv-soap/datasource/all 时,出现错误“无法访问服务器”。我还在主机文件中将本地主机映射到域名。
非常感谢任何帮助。
问题出在代理通行证上。我已经进行了下面提到的更正。
更正前:
RedirectMatch ^/metadata-agent$ /metadata-agent/
ProxyPass /metadata-agent/ http://localhost:8084/ nocanon
ProxyPassReverse /metadata-agent/ http://localhost:8084/
RedirectMatch ^/tdv$ /tdv/
ProxyPass /tdv/ http://localhost:9400/ nocanon
ProxyPassReverse /tdv/ http://localhost:9400/
更正后:
RedirectMatch ^/metadata-agent$ /metadata-agent/
ProxyPass / http://localhost:8084/ nocanon
ProxyPassReverse / http://localhost:8084/
RedirectMatch ^/tdv$ /tdv/
ProxyPass / http://localhost:9400/ nocanon
ProxyPassReverse / http://localhost:9400/
这已解决问题。
我正在尝试设置反向代理以将 https 请求重定向到 HTTP URL。我有一个 java 应用程序,它启动 tomcat 并在那个 tomcat 实例上托管一些服务。
另一个应用程序将使用 https 调用这些服务,这应该重定向到 http url。下面是我做的代理配置。
在 httpd.conf 中启用了 mod_ssl.so、mod_proxy.so 和 mod_proxy_http.so 模块。并且还在 IFModule 下面添加到同一文件。
<IfModule ssl_module>
Listen 443
</IfModule>
以下是 vhosts.conf 文件的内容。
<VirtualHost *:443>
ServerName domain.name.com
ServerAdmin admin@domain.com
DocumentRoot C:/Apache24/htdocs
# ErrorLog ${APACHE_LOG_DIR}/error.log
# CustomLog ${APACHE_LOG_DIR}/access.log combined
SSLEngine On
SSLCertificateFile /certificate_path
SSLCertificateKeyFile /privatekey_path
SSLCertificateChainFile /chain_cert_path
AllowEncodedSlashes NoDecode
RequestHeader set X-Forwarded-Proto "https"
RequestHeader set X-Forwarded-Port "443"
ProxyRequests Off
<Proxy *>
AddDefaultCharset Off
Order deny,allow
Allow from all
</Proxy>
RedirectMatch ^/metadata-agent$ /metadata-agent/
ProxyPass /metadata-agent/ http://localhost:8084/ nocanon
ProxyPassReverse /metadata-agent/ http://localhost:8084/
RedirectMatch ^/tdv$ /tdv/
ProxyPass /tdv/ http://localhost:9400/ nocanon
ProxyPassReverse /tdv/ http://localhost:9400/
ProxyErrorOverride Off
ProxyPassReverseCookieDomain domain.name.com localhost
ProxyPassReverseCookiePath / /
ProxyPreserveHost on
SSLProxyEngine On
SSLProxyCheckPeerCN off
SSLProxyCheckPeerExpire off
</VirtualHost>
我已经尝试了 SOF 中所有可能的答案。但没有任何效果。我收到以下回复 URL:
http://localhost:8084/tdv-soap/datasource/all
当我将其替换为 https://domain.name.com/tdv-soap/datasource/all 时,出现错误“无法访问服务器”。我还在主机文件中将本地主机映射到域名。
非常感谢任何帮助。
问题出在代理通行证上。我已经进行了下面提到的更正。
更正前:
RedirectMatch ^/metadata-agent$ /metadata-agent/
ProxyPass /metadata-agent/ http://localhost:8084/ nocanon
ProxyPassReverse /metadata-agent/ http://localhost:8084/
RedirectMatch ^/tdv$ /tdv/
ProxyPass /tdv/ http://localhost:9400/ nocanon
ProxyPassReverse /tdv/ http://localhost:9400/
更正后:
RedirectMatch ^/metadata-agent$ /metadata-agent/
ProxyPass / http://localhost:8084/ nocanon
ProxyPassReverse / http://localhost:8084/
RedirectMatch ^/tdv$ /tdv/
ProxyPass / http://localhost:9400/ nocanon
ProxyPassReverse / http://localhost:9400/
这已解决问题。