Nginx域名配置(nginx域名配置不生效)
对于想搭建自己博客或者其他个人网站的小伙伴,可能会需要配置域名。
在我们购买完服务器,代码敲完,项目搞定,怎么使用域名访问呢?
首先购买域名(要有DNS解析)-> 然后域名备案与审核 -> 最后将域名与自己服务器的ip挂载上。
最后,执行nginx配置,在保证通过ip可以访问地址时,在nginx更新以下配置即可。注意80端口。

worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
server {
listen 80;
server_name www.xxx.com;
charset utf-8;
location / {
root C:\data\project\ui;
try_files $uri $uri/ /index.html;
index index.html index.htm;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
}
