微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

linux – NGINX不显示Amazon EC2实例上的默认页面

我在Fedora上安装了Nginx.但我不知道为什么我不能通过浏览器请求服务器IP来获取认的Nginx页面.我的请求因超时而下降.

但是Nginx正在运行.

$sudo service Nginx status
Nginx (pid  20372) is running...

我的生成配置是

# For more @R_308_4045@ion on configuration, see:
#   * Official English Documentation: http://Nginx.org/en/docs/
#   * Official Russian Documentation: http://Nginx.org/ru/docs/

user Nginx;
worker_processes auto;
error_log /var/log/Nginx/error.log;
pid /var/run/Nginx.pid;

events {
    worker_connections 1024;
}

http {
    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  /var/log/Nginx/access.log  main;

    sendfile            on;
    tcp_nopush          on;
    tcp_nodelay         on;
    keepalive_timeout   65;
    types_hash_max_size 2048;

    include             /etc/Nginx/mime.types;
    default_type        application/octet-stream;

    # Load modular configuration files from the /etc/Nginx/conf.d directory.
    # See http://Nginx.org/en/docs/ngx_core_module.html#include
    # for more @R_308_4045@ion.
    include /etc/Nginx/conf.d/*.conf;

    index   index.html index.htm;

    server {
        listen       80 default_server;
        listen       [::]:80 default_server;
        server_name  localhost;
        root         /usr/share/Nginx/html;

        # Load configuration files for the default server block.
        include /etc/Nginx/default.d/*.conf;

        location / {
        }

        # redirect server error pages to the static page /40x.html
        #
        error_page 404 /404.html;
            location = /40x.html {
        }

        # redirect server error pages to the static page /50x.html
        #
        error_page 500 502 503 504 /50x.html;
            location = /50x.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${
        #    root           html;
        #    fastcgi_pass   127.0.0.1:9000;
        #    fastcgi_index  index.PHP;
        #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
        #    include        fastcgi_params;
        #}

        # deny access to .htaccess files, if Apache's document root
        # concurs with Nginx's one
        #
        #location ~ /\.ht {
        #    deny  all;
        #}
    }

# Settings for a TLS enabled server.
#
#    server {
#        listen       443 ssl;
#        listen       [::]:443 ssl;
#        server_name  localhost;
#        root         /usr/share/Nginx/html;
#
#        ssl_certificate "/etc/pki/Nginx/server.crt";
#        ssl_certificate_key "/etc/pki/Nginx/private/server.key";
#        # It is *strongly* recommended to generate unique DH parameters
#        # Generate them with: openssl dhparam -out /etc/pki/Nginx/dhparams.pem 2048
#        #ssl_dhparam "/etc/pki/Nginx/dhparams.pem";
#        ssl_session_cache shared:SSL:1m;
#        ssl_session_timeout  10m;
#        ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
#        ssl_ciphers HIGH:SEED:!aNULL:!eNULL:!EXPORT:!DES:!RC4:!MD5:!PSK:!RSAPSK:!aDH:!aECDH:!EDH-DSS-DES-CBC3-SHA:!KRB5-DES-CBC3-SHA:!SRP;
#        ssl_prefer_server_ciphers on;
#
#        # Load configuration files for the default server block.
#        include /etc/Nginx/default.d/*.conf;
#
#        location / {
#        }
#
#        error_page 404 /404.html;
#            location = /40x.html {
#        }
#
#        error_page 500 502 503 504 /50x.html;
#            location = /50x.html {
#        }
#    }

}

我不知道发生了什么. /var/log/Nginx/access.log和/var/log/Nginx/access.log也是空的.请帮忙…

解决方法:

在Amazon EC2上,您需要打开防火墙以允许从浏览器到实例的传入HTTP连接.

>登录Amazon Web Console
>转到EC2
>找到你的实例
>单击其安全组
>单击“入站”选项卡
>单击“编辑”
>添加规则 – > HTTP,将Source字段设置为My Ip

更改将立即生效.

请注意,如果您从非固定IP(咖啡店wifi)访问您的实例,则每次连接时都需要更改源IP地址并获得新的IP地址.所以,如果它有效,然后过了一段时间,它似乎挂了,这可能就是原因.

如果您还要提供HTTPS,则还要添加特定规则.

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐