主机:阿里云ECS
环境:CentOS 7.6
反向代理和重定向都没有成功
PS:发现就连默认配置的欢迎页面也进不去...
default.conf
配置如下:
server {
listen 80;
server_name 127.0.0.1;
error_page 500 502 503 504 /50x.html;
location / {
root /usr/share/nginx/html;
index index.html index.htm;
}
location /api {
proxy_pass http://127.0.0.1:5000;
proxy_set_header X-Real-IP $remote_addr;
}
location /baidu {
return 302 https://www.baidu.com$request_uri;
}
}
运行状态:
$ ps -ef |grep nginx
root 31126 1 0 02:42 ? 00:00:00 nginx: master process /usr/sbin/nginx -c /etc/nginx/nginx.conf
nginx 31127 31126 0 02:42 ? 00:00:00 nginx: worker process
root 31155 13304 0 02:46 ? 00:00:00 /opt/appnode/agent/apps/nginx/anapp-nginx
root 31212 31187 0 02:51 pts/0 00:00:00 grep --color=auto nginx
检查配置文件:
$ nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
预期是:
访问 http://<主机IP>
会进入nginx的欢迎页面
访问 http://<主机IP>/api
会调用5000端口
访问 http://<主机IP>/baidu
则会重定向到baidu
请问这会是什么原因呢?
应该如何排查?
谢谢!!!
服务器名设成这个
你只能用
http://127.0.0.1/
来访问,改改吧