Does the nginx configuration not take effect?

Host: Ali Cloud ECS
Environment: CentOS 7.6

neither reverse proxy nor redirection succeeded

PS: found that even the default welcome page cannot be accessed.

default.conf is configured as follows:

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;
    }
}

running status:

$ 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

check configuration file:

$ nginx -t

nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

it is expected that
visit http://< host IP > will enter the welcome page of nginx
visit http://< host IP > / api will call port 5000
access http://< host IP > / baidu will be redirected to baidu

what could be the reason for this?
how should I troubleshoot?
Thank you!

May.20,2022

the server name is set to this

server_name                127.0.0.1;

you can only use http://127.0.0.1/ to access it. Change it


how about commenting out server_name?


you configure nginx.conf try


your server_name 127.0.0.1; listens to the local computer, so you cannot access it from the public network.

can only be tested on this machine through terminal with curl, wget
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e8a167-6871a.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e8a167-6871a.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?