mod_rewrite apache反向代理(重定向到内部链接)

时间:2020-10-22 03:55:41

标签: apache mod-rewrite url-rewriting

我尝试将 https:// ?do_something 之类的URL重定向到 https:// ?do_other_things 如果被调用的URL 不包含?do_something。 表示: https:// 的调用应重定向到https:// ?do_other_things

我尝试使用外部URL来获得此功能,效果很好。但是使用URL时,URL是由我们的反向代理管理的,所以它没有循环。

我的配置:

# test rewrite

<VirtualHost *:443>

        #  General setup for the virtual host
        #DocumentRoot "/srv/www/htdocs"
        ServerName <mydomain>.de
        #ServerAdmin webmaster@example.com
        ErrorLog /var/log/apache2/<domain>_error_log
        TransferLog /var/log/apache2/<domain>i_access_log

        RequestHeader unset Cookie
       
        #   SSL Engine Switch:
        #   Enable/Disable SSL for this virtual host.
        SSLEngine on

        RewriteEngine on
        SSLProxyEngine on
        RewriteCond %{QUERY_STRING} !\?do_something.*
        RewriteRule ^(.*)$ https://<URL what is handled by this proxy>?do_other_things [P]
        # external URL works fine
        #RewriteRule ^(.*)$ https://www.google.de/maps/ [R=302,L]
       
        #   You can use per vhost certificates if SNI is supported.
        SSLCertificateFile <location_to_cert>
        SSLCertificateKeyFile <location_to_key>
        SSLCertificateChainFile <location_to_root_ca>

        #reverse proxy url to internal webserver
        ProxyPass / http://192.168.1.50:8099/
        ProxyPassReverse / http://192.168.1.50:8099/
       
        #   Per-Server Logging:
        #   The home of a custom SSL log file. Use this when you want a
        #   compact non-error SSL logfile on a virtual host basis.
        CustomLog /var/log/apache2/request_log   ssl_combined

</VirtualHost>
# end test rewrite

错误日志说:

[2020年10月21日星期三20:28:06.738679] [proxy_http:error] [pid 5091](103)软件导致连接中止:[客户端192.168.1.15:44566] AH01102:从远程服务器:443读取状态行时出错

[2020年10月21日星期三20:28:06.738723] [proxy:error] [pid 5091] [client 192.168.1.15:44566] AH00898:从/error/HTTP_BAD_GATEWAY.html.var返回的远程服务器读取错误>

0 个答案:

没有答案
相关问题