一、nginx.conf
nginx.conf 添加子配置文件的路径, *.conf 表示读取所有.conf 结尾的配置
nclude /usr/local/nginx/conf/server/*.conf;
完整如下
除了 nclude /usr/local/nginx/conf/server/*.conf;
,其他为 nginx 安装后的默认配置,只删除了注释内容,未改动
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
include /usr/local/nginx/conf/server/*.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 html;
}
}
}
二、添加 xxxx.conf (注意目录, nginx.conf 配置的对应目录)
1、添加配置文件
2、直接配置相关配置, 如下:
## 正式服配置
# websocket支持 start
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
# websocket支持 end
# 502 bad gateway 错误解决配置
proxy_buffer_size 128k;
proxy_buffers 32 64k;
proxy_busy_buffers_size 256k;
# 502 bad gateway 错误解决配置
# 文件上传大小
client_max_body_size 200m;
### api 服务端地址
server {
listen 80;
server_name yabei.api.520ban.com;
client_max_body_size 200m; #文件最大大小
proxy_connect_timeout 600; #设置超时时间
proxy_read_timeout 600;
proxy_send_timeout 600;
location / {
# 跨域配置
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Real-PORT $remote_port;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
# 路由配置
proxy_pass http://127.0.0.1:9049;
# 405错误- Apache、IIS、Nginx等绝大多数web服务器,都不允许静态文件响应POST请求,否则会返回“HTTP/1.1 405 Method not allowed”错误
error_page 405 =200 http://$host$request_uri;
# 启用支持websocket连接
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
}
### 管理端地址
server {
listen 80;
server_name yabei.manage.520ban.com;
location ^~/oss/ {
proxy_pass http://yabei.api.520ban.com;
}
location ^~/yb/ {
proxy_pass http://yabei.api.520ban.com/;
}
location / {
alias /usr/local/work/yabei/manage/; # 管理端静态资源路径
index index.html index.htm;
try_files $uri $uri/ /index.html =404;
}
}
### 医生端地址
server {
listen 80;
server_name yabei.520ban.com;
location ^~/oss/ {
proxy_pass http://yabei.api.520ban.com;
}
location ^~/yb/ {
proxy_pass http://yabei.api.520ban.com/;
}
location / {
alias /usr/local/work/yabei/doctor/; # 医生端静态资源路径
index index.html index.htm;
try_files $uri $uri/ /index.html =404;
}
}
-
个人开源项目(通用后台管理系统)–> https://gitee.com/wslxm/spring-boot-plus2 , 喜欢的可以看看
-
本文到此结束,如果觉得有用,动动小手点赞或关注一下呗,将不定时持续更新更多的内容…,感谢大家的观看!