无法从外部 IP 访问 Nginx

无法从外部 IP 访问 Nginx

请原谅我提出这个完全是新手的问题,但我对此感到非常困惑。

我跟着本教程在 Ubuntu 18.04 无头服务器上部署 rails 应用程序。我使用 Phusion Passenger 和 Nginx 来为它提供服务。它当前在端口 80 上运行,应用程序的源代码位于/home机器上某个用户的目录中。我已将路由器配置为公开端口 80,将所有请求路由到该服务器。我可以使用路由器分配给服务器的 IP 地址在浏览器中查看 rails 应用程序,但无法通过外部 IP 地址访问它。我做错了什么?

nginx.conf

应用程序配置

server {
  listen 80;
  listen [::]:80;

  server_name _;
  root /home/minecraft/rails_app/current/rails_app/public;

  passenger_enabled on;
  passenger_app_env production;
  passenger_app_root /home/minecraft/rails_app/current/rails_app;

  # Allow uploads up to 100MB in size
  client_max_body_size 100m;

  location ~ ^/(assets|packs) {
    expires max;
    gzip_static on;
    add_header Cache-Control public;
  }
}

http-passenger-conf.d

### Begin automatically installed Phusion Passenger config snippet ###
passenger_root /usr/lib/ruby/vendor_ruby/phusion_passenger/locations.ini;
passenger_ruby /home/minecraft/.rbenv/shims/ruby;
### End automatically installed Phusion Passenger config snippet ###

nginx.conf

worker_processes auto;
pid /run/nginx.pid;
include /etc/nginx/modules-enabled/*.conf;

events {
        worker_connections 768;
        # multi_accept on;
}

http {

        ##
        # Basic Settings
        ##

        sendfile on;
        tcp_nopush on;
        tcp_nodelay on;
        keepalive_timeout 65;
        types_hash_max_size 2048;
        # server_tokens off;

        # server_names_hash_bucket_size 64;
        # server_name_in_redirect off;

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

        ##
        # SSL Settings
        ##

        ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
        ssl_prefer_server_ciphers on;

        ##
        # Logging Settings
        ##

        access_log /var/log/nginx/access.log;
        error_log /var/log/nginx/error.log;

        ##
        # Gzip Settings
        ##

        gzip on;

        # gzip_vary on;
        # gzip_proxied any;
        # gzip_comp_level 6;
        # gzip_buffers 16 8k;
        # gzip_http_version 1.1;
        # gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;

        ##
        # Virtual Host Configs
        ##

        include /etc/nginx/conf.d/*.conf;
        include /etc/nginx/sites-enabled/*;
}

sudo netstat -tanpl | grep nginx

tcp        0      0 0.0.0.0:8080            0.0.0.0:*               LISTEN      13706/nginx: master
tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      13706/nginx: master
tcp6       0      0 :::8080                 :::*                    LISTEN      13706/nginx: master
tcp6       0      0 :::80                   :::*                    LISTEN      13706/nginx: master

sudo ufw status

Status: inactive

相关内容