Can server_name be set to the ip address in nginx?

in nginx, can server_name be set to the ip address?

server {

    listen 8000;
    server_name 101.20.32.76;
    
    access_log /data/ldl/logs/101.20.32.76.access.log  main;
    
    location /index01.html {
        
        alias /data/ldl/repo/QQpro/index01.html;
    }
Mar.10,2021

Yes,

If someone makes a request using an IP address instead of a server name, the "Host" request header field will contain the IP address and the request can be handled using the IP address as the server name:

authoritative notes in official documents http://nginx.org/en/docs/http.


there is no point in writing ip (here you want to follow a host name), that can write an underscore (_) or not write server_name


). Server_name sets ip to point to ip, sets localhost to point to local, and sets domain name to point to domain name


. If you use ip, it is more often used to reverse proxy to other servers. If you use ip locally to implement vhosts, you may need multiple ports.

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-1b3de7d-34798.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-1b3de7d-34798.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?