Home  >  Q&A  >  body text

nginx server_name configuration

My host does not have a domain name yet, what should I fill in for server_name?

阿神阿神2714 days ago881

reply all(3)I'll reply

  • 某草草

    某草草2017-05-16 17:11:38

    You can fill in the IP address. Either leave it blank or fill it in casually and let this configuration be the default.

    nginx is based on server_name 匹配 HTTP 请求头的 host,去决定使用那个 server。host 的值浏览器默认填写域名。如果所有server_name都匹配不到就使用默认的server, so writing this is the most reliable:

    server {
        listen      80 default_server;
    }

    If if if nonedefault_server默认的就是第一个server.

    There is no need to distinguish when there is only one. Without a domain name, you can only create one on one portserver.

    reply
    0
  • 大家讲道理

    大家讲道理2017-05-16 17:11:38

    Are you saying that you haven’t purchased a domain name yet? You can configure hosts to resolve to a fixed server yourself.

    # localhost name resolution is handled within DNS itself.

    # Server IP your_server_name

    Configure vhost in Nginx to the specific parsing server file path:

    server{
    ...
    # Your server domain name
    server_name your_server_name;
    # Your file path
    root /data/dev/..../;
    ...
    }

    reply
    0
  • 为情所困

    为情所困2017-05-16 17:11:38

    If not, you can adjust the IP first, and then you can add it when you have a domain name

    reply
    0
  • Cancelreply