[英]apache2 reverse proxy configuration
我有一個監聽TCP 127.0.0.1:81的應用程序。 我想完成以下重定向:
www.example.com/?requestid=123456 --> http://127.0.0.1:81/?requestid=123456
www.example.com/ANYTHING_ELSE --> MY_IP_THAT_APACHE_LISTENS_ON
我的理解是,如果我不明確重寫某些內容,它將遵循/ var / www / html的常規路徑。
我的/etc/apache2/sites-enabled/000-default.conf配置:
<VirtualHost *:80>
ServerName example.com
ServerAdmin example@example.com
DocumentRoot /var/www/html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
<Location />
RewriteEngine On
RewriteRule ^/?requestid(.*)$ http://127.0.0.1:81/$1 [P]
ProxyPassReverse http://127.0.0.1:81/
Order allow,deny
Allow from all
</Location>
</VirtualHost>
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
為什么它不能正確重寫並不斷打正常補丁?
Not Found
The requested URL /bullshit was not found on this server.
Apache/2.4.25 (Debian) Server at example.com Port 80
在VirtualHost上下文中,模式將首先與主機名和端口之后,查詢字符串(例如“ /app1/index.html”)之前的URL部分匹配。 這是(%解碼)URL路徑。
如果希望與主機名,端口或查詢字符串匹配,請分別使用RewriteCond和%{HTTP_HOST},%{SERVER_PORT}或%{QUERY_STRING}變量。
因此,您將需要以下內容:
RewriteEngine On
RewriteCond %{QUERY_STRING} requestid=(.+)
RewriteRule ^/$ http://127.0.0.1:81/?requestid=%1 [P]
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.