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

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

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

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的时候都报下面这个错误:
nginx配置后访问公网ip显示welcome to nginx, 但是在公网后面带上路由地址显示404?


回答:

Location = / {

return 301 http://47.105.180.30/html/group/group.html;

}

Location --> location

先把这个改了


回答:

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


回答:

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

以上是 nginx配置后访问公网ip显示welcome to nginx, 但是在公网后面带上路由地址显示404? 的全部内容, 来源链接: utcz.com/p/937602.html

回到顶部