nginx配置后访问公网ip显示welcome to nginx, 但是在公网后面带上路由地址显示404?

  1. nginx配置后访问公网ip显示welcome to nginx, 但是在公网后面带上路由地址显示404?

图片描述

图片描述

下面是nginx配置:

# configuration of the server
upstream frontends {
    server 127.0.0.1:8888;
}
server {
    # the port your site will be served on
    listen      80;
    # the domain name it will serve for
    server_name 47.105.180.30; # substitute your machine's IP address or FQDN
    charset     utf-8;

    # max upload size
    client_max_body_size 75M;   # adjust to taste

    # Django media
    location ^~ /html/ {
            root /root/projects/demo-html;
            if ($query_string) {
                expires max;
            }
        }

        location ^~ /static/ {
            root /root/projects/demo-html;
            if ($query_string) {
                expires max;
            }
        }

        location ^~ /css/ {
            root /root/projects/mxforum-html;
            if ($query_string) {
                expires max;
            }
        }

        location ^~ /js/ {
            root /root/projects/demo-html;
            if ($query_string) {
                expires max;
            }
        }

        location ^~ /fonts/ {
            root /root/projects/demo-html;
            if ($query_string) {
                expires max;
            }
        }

        location ^~ /images/ {
            root /root/projects/demo-html;
            if ($query_string) {
                expires max;
            }
        }
        location = /login.html {
            root   /root/projects/demo-html;
        }

    location = /register.html {
            root   /root/projects/demo-html;
        }

        location = / {
            return 301 http://47.105.180.30/html/group/group.html;
        }

    # Finally, send all non-media requests to the Django server.
    location / {
            proxy_pass http://127.0.0.1:8888/;
            proxy_redirect default;
        }
}

我不是直接修改的nginx的nginx.conf, 而是在/etc/nginx/conf.d/下面加了个自己配置的nginx文件.每次修改完这个文件重启nginx的时候都报下面这个错误:
图片描述

阅读 4.9k
3 个回答
Location = / {
            return 301 http://47.105.180.30/html/group/group.html;
        }

Location --> location

先把这个改了

你查下是不是端口被占用导致的启动失败,应该是服务没停,你就启动了,netstat -tpnl | grep 80

云服务器安全组未设置端口

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题