部署nginx遇到了问题
问题:最近做部署,部署nginx的时候我我配置的server_name(域名和公网ip绑定了),访问域名,有时候是正常的配置的页面,有时候是nginx的默认欢迎页面,进入服务器后,curl 127.0.0.1出现的是我配置的页面,curl域名,出现的是nginx的默认页面,等几分钟后,再次访问则是正常的
配置文件
# /etc/nginx/conf.d/demo.conf
server {
listen 80;
server_name obxxx.com;
client_max_body_size 2048m;
client_body_in_file_only clean;
client_body_buffer_size 256K;
proxy_read_timeout 240s;
keepalive_timeout 30;
uwsgi_read_timeout 30m;
location / {
root /home/mx/xx/xx/front/dist;
index index.html;
}
location ~ /api/ {
proxy_pass http://192.168.50.10:7888; # 反向代理网关
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
location ~ /ws {
proxy_pass http://192.168.50.10:8001;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Host $server_name;
}
}
开始以为是/etc/nginx/sites-enabled/default配置文件冲突了,将defualt文件监听80的server块注释了,但是无效,配置其他的nginx访问报错404,不知道往哪个方向排查,急的挠头