
我已經在客戶端的 Digital Ocean Node.js Ubuntu 14.04 Droplet 上安裝了 nginx,sudo apt-get install nginx
但我無法從 Web 瀏覽器存取伺服器的靜態檔案。之前在我自己的其他相同伺服器上安裝過幾次nginx,我從未遇到任何問題,所以我認為這一定是客戶端自己改變的。
我檢查了所有正在運行的進程並ps aux | grep nginx
返回:
root 13060 0.0 0.1 85880 1336 ? Ss 18:44 0:00 nginx: master p
rocess /usr/sbin/nginx
www-data 13061 0.0 0.1 86220 1764 ? S 18:44 0:00 nginx: worker p
rocess
www-data 13062 0.0 0.1 86220 1764 ? S 18:44 0:00 nginx: worker p
rocess
www-data 13063 0.0 0.1 86220 1764 ? S 18:44 0:00 nginx: worker p
rocess
www-data 13064 0.0 0.1 86220 1764 ? S 18:44 0:00 nginx: worker p
rocess
sysadmin 13080 0.0 0.0 11740 932 pts/0 S+ 19:23 0:00 grep --color=au
to nginx
我檢查了連接埠 80,nmap -p 80 localhost
它返回:
Nmap scan report for localhost (127.0.0.1)
Host is up (0.00012s latency).
PORT STATE SERVICE
80/tcp open http
我正在使用default
中的配置sites-available
,並已確認它在 中進行了符號連結sites-enabled
。我已經檢查了預設配置與另一個預設安裝的配置,兩者是相同的。我嘗試將 nginx 根資料夾更改為 /home/user 並在其中放置一個帶有“Hello World”的index.html。瀏覽器上仍然沒有任何內容,它只是傳回 ERR_CONNECTION_TIMED_OUT。
我對 Linux 或 Nginx 沒有太多經驗,但我寧願自己解決這個問題,也不願詢問客戶是否更改了伺服器上的某些內容。我該如何開始調試這裡的問題?
答案1
我建議暫時停用您的防火牆;如果您可以在瀏覽器中訪問該網站,則表示防火牆阻止了連接,在這種情況下,您必須允許該連接埠拋出防火牆。
希望這可以幫助。