
兩個 Web 伺服器,綁定到 127.0.0.1:8080 和 127.0.0.1:8081。 Curl 驗證它們按預期工作。
Apache 具有以下主機:
Host 192.168.1.1:80
<VirtualHost 192.168.1.1:80>
ServerAdmin [email protected]
ProxyPass / http://127.0.0.1:8080/
ProxyPassReverse / http://127.0.0.1:8080/
ServerName 192.168.1.1
ServerAlias http://192.168.1.1
</VirtualHost>
Host 192.168.1.2:80
<VirtualHost 192.168.1.2:80>
ServerAdmin [email protected]
ProxyPass / http://127.0.0.1:8081/
ProxyPassReverse / http://127.0.0.1:8081/
ServerName 192.168.1.2
ServerAlias http://192.168.1.2
</VirtualHost>
在伺服器上,我可以捲曲到主機並收到適當的回應。 (curl 192.168.1.1 提供我來自 localhost:8080 的 Web 伺服器回應)
遠端主機根本無法連線到 192.168.1.1 或 .2。我缺什麼?
回覆:評論
是的,預設目錄指令仍然存在。
# Deny access to root file system
<Directory />
Options None
AllowOverride None
Order Deny,Allow
deny from all
</Directory>
嘗試遠端存取 192.168.1.1 時不會產生 apache 日誌。它們是在本地捲曲時產生的。
如果我將網頁伺服器綁定到 *:8080 和 *:8081 而不是綁定到本機,我可以透過 192.168.1.1 和 192.168.1.2 從遠端主機存取它們。
編輯2:
curl 詳細輸出:(與第二個網頁伺服器和 127.0.0.1:portnum 類似)
[user@host mingle_12_2_1]$ curl -v 192.168.1.1
* About to connect() to 192.168.1.1 port 80
* Trying 192.168.1.1... connected
* Connected to 192.168.1.1 (192.168.1.1) port 80
> GET / HTTP/1.1
> User-Agent: curl/7.15.5 (x86_64-redhat-linux-gnu) libcurl/7.15.5 OpenSSL/0.9.8b zlib/1.2.3 libidn/0.6.5
> Host: 192.168.1.1
> Accept: */*
>
< HTTP/1.1 302 Found
< Date: Tue, 16 Oct 2012 16:22:08 GMT
< Server: Jetty(6.1.19)
< Cache-Control: no-cache
< Location: http://192.168.1.1/install
< X-Runtime: 130
< Content-Type: text/html; charset=utf-8
< Content-Length: 94
< Connection: close
Closing connection #0
<html><body>You are being <a href="http://192.168.1.1/install">redirected</a>.</body></html>
從請求本地記錄
192.168.1.1 - - [16/Oct/2012:12:22:08 -0400] "GET / HTTP/1.1" 302 94
來自遠端客戶端的請求時不會產生 apache 存取日誌或錯誤日誌。
編輯3
除了使用的 IP 位址之外,兩台主機的curl 和日誌都是相同的。與安全管理員合作以獲取鎖定規則以獲取更多資訊。
答案1
由於 proxypass 設定完全在(虛擬)URL 空間中執行,因此您需要透過 Location 指令授予對每個虛擬主機的存取權限:
<VirtualHost 192.168.1.1:80>
ServerAdmin [email protected]
ProxyPass / http://127.0.0.1:8080/
ProxyPassReverse / http://127.0.0.1:8080/
ServerName 192.168.1.1
<Location />
Order allow,deny
Allow from All
</Location>
</VirtualHost>
另外,如果您不使用 NameVirtualHosts,請刪除它們,且 ServerName 必須是主機名,沒有方案或連接埠或其他任何內容。只是一個主機名稱。
答案2
你能提供:
- 捲曲語法/輸出(使用詳細)
- 來自阿帕契的日誌
- ifconfig 輸出
- 貓 /etc/hosts
- 防火牆規則集
- SELinux 啟用/停用?
* 更新 *
您還ServerAlias
應該刪除http://
不需要的部分,更不用說因為您的ServerName
內容與 相同ServerAlias
,ServerAlias
所以只是不需要。