- 工信部備案號 滇ICP備05000110號-1
- 滇公安備案 滇53010302000111
- 增值電信業(yè)務(wù)經(jīng)營(yíng)許可證 B1.B2-20181647、滇B1.B2-20190004
- 云南互聯(lián)網(wǎng)協(xié)會(huì )理事單位
- 安全聯(lián)盟認證網(wǎng)站身份V標記
- 域名注冊服務(wù)機構許可:滇D3-20230001
- 代理域名注冊服務(wù)機構:新網(wǎng)數碼
Ubuntu 12.04使用Apache的ProxyPass配置反向代理
在某些情況下,雖然Apache已經(jīng)能滿(mǎn)足其大多數通用Web服務(wù)需求,但其他Web或應用程序服務(wù)器更適合某些任務(wù)。 幸運的是,很容易配置Apache將某些請求傳遞到其他Web服務(wù)器進(jìn)程。 這些輔助(或第三)web服務(wù)器可以在相同的服務(wù)器或單獨的節點(diǎn)(可能通過(guò)專(zhuān)用網(wǎng)絡(luò ))上運行。 我們的示例使用lighttpd作為輔助Web服務(wù)器,但它們也可以代理HTTP請求到任何Web服務(wù)器或應用程序。
激活Proxy模塊
按如下內容編輯/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>
這將啟用代理支持。
下一步,執行下命令:
a2enmod proxy a2enmod proxy_http service apache2 restart
Apache應該能正常重新啟動(dòng)。如果您遇到任何問(wèn)題,您可以檢查/var/log/apache2/下的日志以獲取更多信息。
我們已經(jīng)有一個(gè)名為“www.tjdsmy.cn”的網(wǎng)站作為正常的虛擬主機在A(yíng)pache下運行。 我們將使用Apache將對“www.tjdsmy.cn”網(wǎng)站的請求發(fā)送到lighttpd,lighttpd運行在端口8080上。 這里是“www.tjdsmy.cn”的配置文件:
/etc/apache2/sites-available/www.tjdsmy.cn:
<VirtualHost *:80> ServerAdmin support@secondsite.org ServerName secondsite.org ServerAlias www.tjdsmy.cn ProxyPass / http://www.tjdsmy.cn:8080/ # Uncomment the line below if your site uses SSL. #SSLProxyEngine On </VirtualHost>
ProxyPass指令告訴Apache將此域的所有請求轉發(fā)到在端口8080上運行的Web服務(wù)器。如果我們的目標服務(wù)器在另一個(gè)服務(wù)器上運行,我們可以指定地址。 我們將使用以下命令啟用該網(wǎng)站:
a2ensite www.tjdsmy.cn service apache2 reload
如果我們想把http://www.tjdsmy.cn/myapp/的請求轉向 lighttpd,我們只需修改其配置文件,如下所示:
/apache2/sites-available/www.tjdsmy.cn:
<VirtualHost *:80> ServerAdmin support@firstsite.org ServerName firstsite.org ServerAlias www.tjdsmy.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://www.tjdsmy.cn:8080/ </VirtualHost>
售前咨詢(xún)
售后咨詢(xún)
備案咨詢(xún)
二維碼
TOP