Home >Backend Development >PHP Tutorial >nginx access denied

nginx access denied

WBOY
WBOYOriginal
2016-07-06 13:53:052449browse

<code>前两天开了个aws免费一年的EC2,我就想买个域名搭个自己的博客练练手。前期都很顺利,可是在绑定域名的时候遇到了麻烦,访问网站时灵时不灵,日志里也看不到不出什么问题。折腾一天了也没什么进展,求各位大神救救俺。
下面是nginx.conf的内容,我还没有配虚拟主机。</code>
<code>user www;
worker_processes  1;

error_log  /opt/modules/nginx/logs/error.log notice;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

pid        /opt/modules/nginx/logs/nginx.pid;


events {
    use  epoll;
    worker_connections  1024;
}


http {
    include       mime.types;
    default_type  application/octet-stream;
    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

    access_log  /opt/modules/nginx/logs/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;

    #gzip  on;

    server {
        listen       80 default;

        #charset koi8-r;

        access_log  /opt/modules/nginx/logs/access.log  main;
        location / {
            root   html;
            index  index.php index.html index.htm;
        }

        #error_page  404              /404.html;

        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }

        # proxy the PHP scripts to Apache listening on 127.0.0.1:80
        #
        #location ~ \.php$ {
        #    proxy_pass   http://127.0.0.1;
        #}

        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #
        location ~ \.php$ {
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
            include        fastcgi_params;
        }
    }
}</code>
<code>日志里没有打印错误,我这里贴下浏览器报错吧:
</code>

nginx access denied

<code>
这个错误诡异在日志没有任何的报错,而且不同的浏览器访问网站情况还不一样。我用chrome访问的时候大概有十分之一的几率访问正常,用Safari的时候却有百分之50的几率访问正常,用IE压根不能正常访问。
网站地址是:http://gaochao.info
</code>
<code>如果访问正常的话会显示nginx欢迎界面。大家也可以试试。

期初我怀疑是域名没能够正常解析,但后来我排除了这个可能。原因有两点:第一我试过直接修改hosts文件,问题没有任何改善。第二我在ping域名的时候:
</code>

nginx access denied

<code>这里显示域名已经被成功解析到我的ip了。所以应该不是解析的问题。

我已经试了各种方法了,还是没能解决这个问题。恳请各位大神救我脱离苦海啊!!!</code>

Reply content:

<code>前两天开了个aws免费一年的EC2,我就想买个域名搭个自己的博客练练手。前期都很顺利,可是在绑定域名的时候遇到了麻烦,访问网站时灵时不灵,日志里也看不到不出什么问题。折腾一天了也没什么进展,求各位大神救救俺。
下面是nginx.conf的内容,我还没有配虚拟主机。</code>
<code>user www;
worker_processes  1;

error_log  /opt/modules/nginx/logs/error.log notice;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

pid        /opt/modules/nginx/logs/nginx.pid;


events {
    use  epoll;
    worker_connections  1024;
}


http {
    include       mime.types;
    default_type  application/octet-stream;
    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

    access_log  /opt/modules/nginx/logs/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;

    #gzip  on;

    server {
        listen       80 default;

        #charset koi8-r;

        access_log  /opt/modules/nginx/logs/access.log  main;
        location / {
            root   html;
            index  index.php index.html index.htm;
        }

        #error_page  404              /404.html;

        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }

        # proxy the PHP scripts to Apache listening on 127.0.0.1:80
        #
        #location ~ \.php$ {
        #    proxy_pass   http://127.0.0.1;
        #}

        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #
        location ~ \.php$ {
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
            include        fastcgi_params;
        }
    }
}</code>
<code>日志里没有打印错误,我这里贴下浏览器报错吧:
</code>

nginx access denied

<code>
这个错误诡异在日志没有任何的报错,而且不同的浏览器访问网站情况还不一样。我用chrome访问的时候大概有十分之一的几率访问正常,用Safari的时候却有百分之50的几率访问正常,用IE压根不能正常访问。
网站地址是:http://gaochao.info
</code>
<code>如果访问正常的话会显示nginx欢迎界面。大家也可以试试。

期初我怀疑是域名没能够正常解析,但后来我排除了这个可能。原因有两点:第一我试过直接修改hosts文件,问题没有任何改善。第二我在ping域名的时候:
</code>

nginx access denied

<code>这里显示域名已经被成功解析到我的ip了。所以应该不是解析的问题。

我已经试了各种方法了,还是没能解决这个问题。恳请各位大神救我脱离苦海啊!!!</code>

In fact, when you see the connection being reset, 99% of the time it means it is blocked!
AWS is blocked and you need to use a proxy to access it.

  • I am in Tokyo and can access http://gaochao.info and http://52.196.247.234/

  • using both chrome and safari.
  • I used IP Location to check your IP (52.196.247.234). The address is in Tokyo, Japan. I think the intermittent convulsions on the website are probably due to being blocked...

  • Switch to domestic cloud services. Or use Hexo to build a blog and deploy it to Coding, which is completely free and very convenient.

It is blocked and can be accessed by overcoming the wall.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn