福建省建设执业资格管理注册中心网站,网站开发课程安排,建设博物馆网站,wordpress文章加字段背景
最近使用某运营商的云服务器作为正式环境服务器#xff0c;申请的时候只申请了一个端口#xff0c;我们的前端页面及后台服务#xff0c;还有minio#xff0c;都需要nginx代理这个端口去进行访问。
server {# 监听端口7878listen 7878;server_name localhost;# 前端…背景
最近使用某运营商的云服务器作为正式环境服务器申请的时候只申请了一个端口我们的前端页面及后台服务还有minio都需要nginx代理这个端口去进行访问。
server {# 监听端口7878listen 7878;server_name localhost;# 前端页面location / {root /home/zx/mima/dist;index index.html index.htm;}# 后端接口地址location /api {proxy_pass http://10.10.40.3:8808;add_header Access-Control-Allow-Origin *;add_header Access-Control-Allow-Methods GET,POST,PUT,DELETE,OPTIONS;add_header Access-Control-Allow-Headers DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization;}# Minio的前端页面location /minio-web/ {proxy_pass http://10.10.10.226:9090/;proxy_http_version 1.1;proxy_set_header Upgrade $http_upgrade;proxy_set_header Connection upgrade;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_set_header X-Forwarded-Proto $scheme;proxy_connect_timeout 5s;proxy_read_timeout 60s;proxy_send_timeout 60s;# 使用sub_filter修改Minio前端页面内部的地址添加/minio-web前缀sub_filter / /minio-web/;sub_filter_once off;# 配置Minio的前端页面代理,静态资源等location ~ ^/minio-web/(.*) {proxy_pass http://10.10.10.226:9090/$1;proxy_http_version 1.1;proxy_set_header Upgrade $http_upgrade;proxy_set_header Connection upgrade;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_read_timeout 86400;proxy_pass_header X-XSRF-TOKEN;proxy_set_header Origin ;}}}一开始我单独使用上面的配置minio的页面包括静态资源文件及接口都没有问题但是在预览和下载文件的时候总是报参数是必须的好像参数没传过去后来我加上了下面的配置算是没有问题了 location /minio-web/api/ {proxy_pass http://10.10.10.226:9090/api/;proxy_http_version 1.1;proxy_set_header Upgrade $http_upgrade;proxy_set_header Connection upgrade;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_set_header X-Forwarded-Proto $scheme;proxy_connect_timeout 5s;
}