1. 程式人生 > >nginx頁面不能正常訪問排除方法

nginx頁面不能正常訪問排除方法

nginx頁面不能訪問

1. 檢查服務端服務是否啟動成功

[root@shizhan02 html]# ps -ef |grep nginx  #檢視nginx服務是否啟動
root       1609      1  0 16:46 ?        00:00:00 nginx: master process nginx
nginx      1610   1609  0 16:46 ?        00:00:00 nginx: worker process
root       1898   1593  0 18:09 pts/0    00:00:00 grep nginx
[root@shizhan02 html]# lsof -i :80  #檢查80埠是否在監聽狀態
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME nginx 1609 root 6u IPv4 11948 0t0 TCP *:http (LISTEN) nginx 1610 nginx 6u IPv4 11948 0t0 TCP *:http (LISTEN)
[root@shizhan02 html]# netstat -lnt |grep 80 
tcp        0      0 0.0.0.0:80                  0.0.0.0:*                   LISTEN

2.在服務端使用wget和curl測試下返回的是否正常

[[email protected] html]# wget 127.0.0.1
--2017-11-20 18:16:58--  http://127.0.0.1/
Connecting to 127.0.0.1:80... connected.
HTTP request sent, awaiting response... 200 OK #返回值200表示連結正常
Length: 612 [text/html]
Saving to: “index.html.2”

100%[===============================================================>] 612         --.-K/s   in 0s      

2017-11-20 18:16:58 (279 MB/s) - “index.html.2” saved [612/612]

[
[email protected]
html]# curl 127.0.0.1 #返回頁面的值表示正常。 <!DOCTYPE html> <html> <head> <title>Welcome to nginx!</title> <style> body { width: 35em; margin: 0 auto; font-family: Tahoma, Verdana, Arial, sans-serif; } </style> </head> <body> <h1>Welcome to nginx!</h1> <p>If you see this page, the nginx web server is successfully installed and working. Further configuration is required.</p> <p>For online documentation and support please refer to <a href="http://nginx.org/">nginx.org</a>.<br/> Commercial support is available at <a href="http://nginx.com/">nginx.com</a>.</p> <p><em>Thank you for using nginx.</em></p> </body> </html>

以上是檢測Nginx在服務端安裝及瀏覽是否正常。

3.瀏覽器,wget或者curl等軟體訪問不了Ngixn頁面。

    1. 關閉SEliun
    ```
    [[email protected] html]# getenforce #檢視iptables狀態,是否為關閉,以下為關閉狀
    態,
    Disabled
    [[email protected] html]# vim /etc/selinux/config #永久關閉iptalbes
    SELINUX=disabled #需要將此行更改為disabled
    SELINUXTYPE=targeted

    [[email protected] html]# setenforce 0 #臨時關閉iptables的方法,如果臨時能夠訪問
    了,那麼久使用下面的方法新增80埠在iptables的配置檔案上
    setenforce: SELinux is disabled

    [[email protected] html]# service iptables status   #檢查iptables
    Table: filter
    Chain INPUT (policy ACCEPT)
    num  target     prot opt source               destination         

    Chain FORWARD (policy ACCEPT)
    num  target     prot opt source               destination         

    Chain OUTPUT (policy ACCEPT)
    num  target     prot opt source               destination  

    問題不是出在nginx上,而是出在iptable上,在iptable上新增80埠

    Linux程式碼  收藏程式碼
    #vi /etc/sysconfig/iptables  
    //在倒數第二行加入80埠  
    -A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j
     ACCEPT  


    //重啟iptables  
    #/etc/init.d/iptables restart  
     再通過ip訪問  ok~  沒問題了
    ```
2. 通過本地客服端測試
    第一步:在客服端ping服務端的ip,我這裡的的服務端為192.168.1.202
    ```
    [[email protected] html]# ping 192.168.1.202
    PING 192.168.1.202 (192.168.1.202) 56(84) bytes of data.
    64 bytes from 192.168.1.202: icmp_seq=1 ttl=64 time=0.014 ms
    64 bytes from 192.168.1.202: icmp_seq=2 ttl=64 time=0.024 ms
    ^C
    --- 192.168.1.202 ping statistics ---
    2 packets transmitted, 2 received, 0% packet loss, time 1814ms
    rtt min/avg/max/mdev = 0.014/0.019/0.024/0.005 ms
    #提示按ctrl+c結束
    ```
    第二步:在客戶端上telnet服務端ip,埠
    ```
    [[email protected] html]# telnet 192.168.1.202 #返回如下資訊表示連結成功
    Trying 192.168.1.202...
    telnet: connect to address 192.168.1.202: Connection refused
    ```

        第三步:在客服端使用wget或者curl命令檢測。
        ```
        [[email protected] html]# curl -i 192.168.1.202
        HTTP/1.1 200 OK
        Server: nginx/1.13.6
        Date: Mon, 20 Nov 2017 10:42:31 GMT
        Content-Type: text/html
        Content-Length: 612
        Last-Modified: Mon, 20 Nov 2017 08:08:26 GMT
        Connection: keep-alive
        ETag: "5a128d7a-264"
        Accept-Ranges: bytes

        <!DOCTYPE html>
        <html>
        <head>
        <title>Welcome to nginx!</title>
        <style>
            body {
                width: 35em;
                margin: 0 auto;
                font-family: Tahoma, Verdana, Arial, sans-serif;
            }
        </style>
        </head>
        <body>
        <h1>Welcome to nginx!</h1>
        <p>If you see this page, the nginx web server is successfully
         installed and
        working. Further configuration is required.</p>

        <p>For online documentation and support please refer to
        <a href="http://nginx.org/">nginx.org</a>.<br/>
        Commercial support is available at
        <a href="http://nginx.com/">nginx.com</a>.</p>

        <p><em>Thank you for using nginx.</em></p>
        </body>
        </html>
        ```
        3. 在瀏覽器訪問輸入如下的內容,伺服器ip.

            http://192.168.1.202/

    ![nginx已經能夠成功訪問](https://img-blog.csdn.net/20171120104737429?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvcXFfMjk3NjczMTc=/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast)
    這裡有一個小小的坑,希望大家注意一下,使用瀏覽器輸入ip訪問的時候,注意清空一下快取,或者重新開啟一下瀏覽器,有可能讓你一直重新整理不出頁面。

相關推薦

nginx頁面不能正常訪問排除方法

nginx頁面不能訪問 1. 檢查服務端服務是否啟動成功 [root@shizhan02 html]# ps -ef |grep nginx #檢視nginx服務是否啟動 root 1609 1 0 16:46

Nginx不能正常訪問排除方法

Nginx頁面不能訪問 1. 檢查服務端服務是否啟動成功 [root@shizhan02 html]# ps -ef |grep nginx #檢視nginx服務是否啟動 root 1609 1 0 16:46 ? 00:00:00 nginx: master p

thinkphp框架寫的專案在nginx下無法正常訪問報錯的原因以及解決方法

nginx環境問題弄了兩天,發現網上很多人的帖子要麼複製貼上,要麼就是沒有結貼,還自己寫一句“哈哈,我自己解決了”之類的,這點我就鄙視這些發帖的同胞了,你說你問題問了,問題解決了也不給個解釋。還在搜尋的前幾頁,想沒想過需要答案的人的感受呢。滿心歡喜的去看答案,發現沒有結貼。好吧,不多說,進入正題。 我這種方

lnmp 搭建後,nginx下php文件404但是html文件正常訪問【已解決】

() stack 找到 span nec mis group php 方法 今天遇到 了如題的問題。 上網查了很多資料 最終是在這個鏈接 裏 找到了能解決我的問題的方法 https://stackoverflow.com/questions/23443398/nginx-e

nginx跟apache訪問方法

gre 配置 1.8 ref 是否 指定 方法 usr 生成 ifconfig 在瀏覽器中輸入ip即可訪問 centos安裝nginx環境 1:進入 cd /usr/local/src //下載文件放到這個目錄中 2:wget http://nginx.org/downl

Nginx由於TLS支持版本配置過低造成不能夠正常訪問Upstream服務器的問題

Nginx Upstream服務器的問題 打開Nginx錯誤日誌,發現報了n多條錯誤:1818/83/88 15:38:83 [crit] 16145#8: 3489687 SSL_do_handshake() failed (SSL: error:14876181:SSL routines:SSL1

nginx代理 前端埠不能正常訪問(504 Gateway Time-out) 一個可能的原因

在使用angular架構時,遇到了前端埠不能正常訪問,(504 Gateway Time-out)的問題,搜了很多方法都不對,最後才發現原來是自己曾執行nginx但沒有主動關閉。 開啟工作管理員看一下,正常情況下nginx的程序只有5個,如果多次開啟nginx,並且沒有正常stop它(ng

設定iptables之後不能正常訪問ftp解決方法

設定了iptables的禁止所有的埠,只容許可能訪問了策略後大部分情況下會出現ftp不能正常訪問的問題,因為ftp有主動和被動連線兩種模式,少新增一些策略就會出問題。    在這裡我就相信的說明下解決方法:    首先載入: #modprobe i

Nginx實現404頁面的三種方法

一個網站專案,肯定是避免不了404頁面的,通常使用Nginx作為Web伺服器時,有以下集中配置方式: 第一種:Nginx自己的錯誤頁面 Nginx訪問一個靜態的html 頁面,當這個頁面沒有的時候,

FileZilla上傳圖片成功,瀏覽器可以正常訪問nginx,但是訪問圖片報404

1、在/usr/local/nginx/html目錄下新建images資料夾         cd  /usr/local/nginx/html         mkdir images 2、新增一個location cd  /usr/local/nginx/conf  

Nginx實現404頁面的幾種方法,你知道幾種

一個網站專案,肯定是避免不了404頁面的,通常使用Nginx作為Web伺服器時,有以下集中配置方式,一起來看看。 第一種:Nginx自己的錯誤頁面 Nginx訪問一個靜態的html 頁面,當這個頁面沒有的時候,Nginx丟擲404,那麼如何返回給客戶端404呢? 看下面的配置,這種情況下不需要修改

struts2中直接訪問jsp頁面報錯解決方法

問題描述: The Struts dispatcher cannot be found.  This is usually caused by using Struts tags without the associated filter. Strut s tags

apache用http://就可以正常訪問到專案,https:訪問的顯示的是 It Works!頁面

問題 使用阿里雲的伺服器部署網站是 http://oldthree.top,現在有需求將其轉換為https://oldthree.top,主要是為了微信小程式的連線測試工作. 在使用阿里雲的證書進行相關配置之後,開啟https://oldthree.top

Nginx禁止ip訪問或IP網段訪問方法

轉載:https://www.cnblogs.com/already/p/6244295.html Nginx禁止ip訪問可以防止指定IP訪問我們的網站,本例子可以實現是防止單IP訪問或IP網段訪問了,非常的有用我們一起來看看吧。 常用的linux做法 iptables參考規則

Nginx配置 Laravel 正常訪問

在nginx.conf 裡對應的server{}中配置如下程式碼location / {            index index.php index.html index.htm;            try_files $uri $uri/ /index.php?$

Nginx limit 限制訪問模組的使用方法

本篇文章主要介紹了Nginx limit 限制訪問模組的方法,小編覺得挺不錯的,現在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧 Nginx 的 limit 模組用於限制 Nginx 的訪問。 limit 模組包含有兩個部分: limit_conn 用於對連線數量的限制 li

jsp 中出現大量紅線,而且頁面正常訪問

第一次,出現這種情況真的很苦惱,估計是有強迫症的原因,就是看著不舒服,都頁面能正常訪問,但是還是想解決它  解決方法:依次按下 ctl+A ctl+X.ctl+V,   沒看錯就是 全選,剪下,貼上

Nginx網站使用CDN之後禁止使用者真實IP訪問方法

做過面向公網WEB的運維人員經常會遇見惡意掃描、拉取、注入等圖謀不軌的行為,對於直接對外的WEB伺服器,我們可以直接通過 iptables 、Nginx 的deny指令或是程式來ban掉這些惡意請求。 而對於套了一層 CDN 或代理的網站,這些方法可能就失效了。尤其是個人網

phpStudy配置虛擬主機後,無法正常訪問指定目錄。

phpstudy 無法 alt http 配置 ima 定義 images 虛擬 報錯如下: 查看你的hosts文件,是否定義過這個站點,或,是否有錯別字。 如果報錯是下面這個的話,很明顯,站點沒有正確的指定到具體的文件(文件夾)。 phpStudy配置虛擬主

web頁面超時自動退出方法

如果 鼠標移動 ready 判斷 web tin 頁面 tint 思路 思路: 使用 mousemover 事件來監測是否有用戶操作頁面,寫一個定時器間隔特定時間檢測是否長時間未操作頁面,如果是,退出; 具體時間代碼如下(js):var lastTime = new Dat