nginx-配置文件详解
详解nginx配置
worker_processes 1; events { worker_connections 1024; } http { include mime.types; default_type application/octet-stream; sendfile on; keepalive_timeout 65; # 主机 一个nginx可以同时运行多个主机 # 通过不同的端口号区分不同的主机 # 开启多个主机的方式叫做虚拟主机vhost # 虚拟主机为了把过剩的主机资源进行利用 # 域名解析:先试试本地hosts文件 ip + 域名 # 购买域名: 阿里云 记录类型 A 主机记录www或*(泛解析) # 主机记录可以配置多个多个路径指向该ip server { # 监听端口 listen 80; # server_name 域名或主机名 # servername匹配规则 # 完整匹配、通配符匹配 、正则匹配 server_name localhost; # 路径匹配上location后面的内容 # 就会进入root目录 # 一个主机可以配置多个不同的location # 不同的location可以进入不同的目录 location / { # root 指根目录对应目录/usr/local/nginx # 这里之/usr/local/nginx/html root html; # index指默认页(主页) index index.html index.htm; } # 错误码 后端服务出错了 就会跳转到50x.html error_page 500 502 503 504 /50x.html; # 为50x.html做路径跳转 访问html目录下的文件 进行显示 location = /50x.html { root html; } } }
分类:
nginx