Nginx简单部署静态页面
环境: CentOS 7 Nginx根目录: /etc/nginx/ 在Nginx根目录下创建一个目录(文件夹),命名为: html。 用于放置页面文件。 编辑 /etc/nginx/conf.d 下的 default.conf( 因为主配置文件 /etc/nginx/nginx.conf 包含了 /etc/nginx/conf.d/ default.conf ) 将 /etc/nginx/nginx.conf 内容修改如下(删除掉了默认的注释内容,先从基础搞起,一点点深入了解配置) : server { listen 80; server_name localhost; location / { root html; # 指定根目录下的静态文件目录(相对) index index.html index.htm; } error_page 500 502 503 504 /50x.html; location = /50x.html { root /usr/share/nginx/html; } # 设置反向代理 location /v/ { proxy_pass http://xxx.com/api/; } } 以上修改了默认端口的访问内容。然后局域网访问(内容包含了一些ajax反向代理请求的内容): index.html内容如下: <!DOCTYPE html> <html