- 工信部備案號 滇ICP備05000110號-1
- 滇公網(wǎng)安備53011102001527號
- 增值電信業(yè)務(wù)經(jīng)營許可證 B1.B2-20181647、滇B1.B2-20190004
- 云南互聯(lián)網(wǎng)協(xié)會理事單位
- 安全聯(lián)盟認證網(wǎng)站身份V標記
- 域名注冊服務(wù)機構(gòu)許可:滇D3-20230001
- 代理域名注冊服務(wù)機構(gòu):新網(wǎng)數(shù)碼
Ubuntu 12.04使用Apache的ProxyPass配置反向代理
在某些情況下,雖然Apache已經(jīng)能滿足其大多數(shù)通用Web服務(wù)需求,但其他Web或應(yīng)用程序服務(wù)器更適合某些任務(wù)。 幸運的是,很容易配置Apache將某些請求傳遞到其他Web服務(wù)器進程。 這些輔助(或第三)web服務(wù)器可以在相同的服務(wù)器或單獨的節(jié)點(可能通過專用網(wǎng)絡(luò))上運行。 我們的示例使用lighttpd作為輔助Web服務(wù)器,但它們也可以代理HTTP請求到任何Web服務(wù)器或應(yīng)用程序。
激活Proxy模塊
按如下內(nèi)容編輯/etc/apache2/mods-available/proxy.conf:
<IfModule mod_proxy.c>
#turning ProxyRequests on and allowing proxying from all may allow
#spammers to use your proxy to send email.
ProxyRequests Off
<Proxy *>
AddDefaultCharset off
Order deny,allow
Allow from all
</Proxy>
# Enable/disable the handling of HTTP/1.1 "Via:" headers.
# ("Full" adds the server version; "Block" removes all outgoing Via: headers)
# Set to one of: Off | On | Full | Block
ProxyVia On
</IfModule>這將啟用代理支持。
下一步,執(zhí)行下命令:
a2enmod proxy a2enmod proxy_http service apache2 restart
Apache應(yīng)該能正常重新啟動。如果您遇到任何問題,您可以檢查/var/log/apache2/下的日志以獲取更多信息。
我們已經(jīng)有一個名為“lncdfzh.com.cn”的網(wǎng)站作為正常的虛擬主機在Apache下運行。 我們將使用Apache將對“lncdfzh.com.cn”網(wǎng)站的請求發(fā)送到lighttpd,lighttpd運行在端口8080上。 這里是“lncdfzh.com.cn”的配置文件:
/etc/apache2/sites-available/lncdfzh.com.cn:
<VirtualHost *:80> ServerAdmin support@secondsite.org ServerName secondsite.org ServerAlias lncdfzh.com.cn ProxyPass / http://lncdfzh.com.cn:8080/ # Uncomment the line below if your site uses SSL. #SSLProxyEngine On </VirtualHost>
ProxyPass指令告訴Apache將此域的所有請求轉(zhuǎn)發(fā)到在端口8080上運行的Web服務(wù)器。如果我們的目標服務(wù)器在另一個服務(wù)器上運行,我們可以指定地址。 我們將使用以下命令啟用該網(wǎng)站:
a2ensite lncdfzh.com.cn service apache2 reload
如果我們想把http://lncdfzh.com.cn/myapp/的請求轉(zhuǎn)向 lighttpd,我們只需修改其配置文件,如下所示:
/apache2/sites-available/lncdfzh.com.cn:
<VirtualHost *:80> ServerAdmin support@firstsite.org ServerName firstsite.org ServerAlias lncdfzh.com.cn DocumentRoot /srv/www/firstsite.org/public_html/ ErrorLog /srv/www/firstsite.org/logs/error.log CustomLog /srv/www/firstsite.org/logs/access.log combined ProxyPass /myapp http://lncdfzh.com.cn:8080/ </VirtualHost>
售前咨詢
售后咨詢
備案咨詢
二維碼

TOP