簡體   English   中英

Apache:先重寫然后再代理

[英]Apache: Rewrite then Proxy

所以,我有兩個服務器,我們稱它們為nice#server和a#another#server

nice#server是客戶端要與之交談的服務器,並且正在運行Apache2,為簡單服務執行基本的反向代理,而另一個#server在port上托管一個專有的應用程序服務器。 我需要完全重寫兩個URL,然后才能通過它們,但只需將文件夾添加到所有其他URL。

以下是一些示例:

User Requests: nice#server/
Apache requests a#another#server:8080/appname

User Requests: nice#server/css#css
Apache requests a#another#server:8080/appname/css#css

User Requests: nice#server/a
Apache requests a#another#server:8080/appname/command1?name=option1

User Requests: nice#server/b
Apache requests a#another#server:8080/appname/app2?name=option2

我已經做了很多谷歌搜索和測試,但似乎無法使其正常工作,對不起,我沒有保留我嘗試過的鏈接! 我現在已經剝離了vHost文件。

<VirtualHost *:80>
  ServerName              service#domain#com
  ErrorLog                ${APACHE_LOG_DIR}/service-domain-com-error.log
  LogLevel                warn
  CustomLog               ${APACHE_LOG_DIR}/service-domain-com-access.log combined
  ProxyPreserveHost       On
  ProxyRequests           off
  ProxyPass               / a#another#server:8080/
  ProxyPassReverse        / a#another#server:8080/
</VirtualHost>

在此先感謝您提供有關此操作的任何指導。

我設法通過一些反復試驗來解決此問題。 如果有人遇到問題,請在此處發布解決方案。

工作配置文件

<VirtualHost *:80>
    ServerName              service.domain.com

    ErrorLog                ${APACHE_LOG_DIR}/internal-fqdn-error.log
    LogLevel                warn
    CustomLog               ${APACHE_LOG_DIR}/internal-fqdn-access.log combined

    RewriteEngine           On
    RewriteRule             ^/a$ /appname/command1?name=option1 [PT]

    ProxyPreserveHost       On
    ProxyRequests           off
    ProxyPass               /       http://a.another.server:8080/
    ProxyPassReverse        /       http://a.another.server:8080/
</VirtualHost>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM