|
|
|
|
events {
|
|
|
|
|
# 工作进程的最大连接数
|
|
|
|
|
worker_connections 1024;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
http {
|
|
|
|
|
# 包含mime.types文件
|
|
|
|
|
include mime.types;
|
|
|
|
|
# 默认文件类型
|
|
|
|
|
default_type application/octet-stream;
|
|
|
|
|
# 开启sendfile功能
|
|
|
|
|
sendfile on;
|
|
|
|
|
|
|
|
|
|
# 保持连接超时时间
|
|
|
|
|
keepalive_timeout 65;
|
|
|
|
|
|
|
|
|
|
# 定义一个server
|
|
|
|
|
server {
|
|
|
|
|
# 监听80端口
|
|
|
|
|
listen 80;
|
|
|
|
|
# 服务器名称
|
|
|
|
|
server_name localhost;
|
|
|
|
|
|
|
|
|
|
# 404页面跳转
|
|
|
|
|
location / {
|
|
|
|
|
# 如果请求的文件不存在,则尝试加载index.html
|
|
|
|
|
try_files $uri /index.html;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# 静态资源目录,即vue打包后的dist里的静态资源
|
|
|
|
|
root /usr/share/nginx/html/;
|
|
|
|
|
# 默认首页
|
|
|
|
|
index index.html index.htm;
|
|
|
|
|
|
|
|
|
|
# 后端服务的配置
|
|
|
|
|
location /api/ {
|
|
|
|
|
# 关闭代理重定向
|
|
|
|
|
proxy_redirect off;
|
|
|
|
|
# 设置代理请求头
|
|
|
|
|
proxy_set_header Host $host;
|
|
|
|
|
proxy_set_header X-Real-IP $remote_addr;
|
|
|
|
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
|
|
|
# 后端服务地址
|
|
|
|
|
proxy_pass http://localhost:9527/api/;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# 错误页面
|
|
|
|
|
error_page 500 502 503 504 /50x.html;
|
|
|
|
|
# 错误页面路径
|
|
|
|
|
location = /50x.html {
|
|
|
|
|
root html;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|