0
点赞
收藏
分享

微信扫一扫

windows部署python+Django+vue项目nginx https配置

windows部署python+Django+vue项目nginx配置

http自动重定向到https

#user  nobody;
worker_processes 1;


events {
worker_connections 1024;
}


http {
include mime.types;
default_type application/octet-stream;


sendfile on;

server {
listen 8088;
server_name localhost;

location / {
root html;
index index.html index.htm;
}

error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}

}



# HTTPS server
# frontend
server {
listen 443 ssl;
server_name xxx.xxx.com;

ssl_certificate D:/Database/ssl/xxxx.pem; # 证书
ssl_certificate_key D:/Database/ssl/private.key;

ssl_session_cache shared:SSL:1m;
ssl_session_timeout 5m;

ssl_ciphers HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on;

location / {
# 前端vue打包好的目录
root E:/xxxxxxxxxx/frontend/idea-dist/dist;
#root E:/indextest;
index index.html index.htm;
try_files $uri $uri/ /index.html;
}
location /api {
proxy_pass http://xxxx.xxxx.com:8181/api; # 后端API访问地址
proxy_set_header X-Real-IP $remote_addr;
}
location /media {
proxy_pass http://xxxxx.xxxx.com:8181/media; # 静态目录访问地址
proxy_set_header X-Real-IP $remote_addr;
}
}
# backend 多端口部署,端口为8585
server {
listen 8585 ssl;
server_name xxxx.xxxx.com;

ssl_certificate D:/Database/ssl/xxxxxx.pem;
ssl_certificate_key D:/Database/ssl/private.key;

ssl_session_cache shared:SSL:1m;
ssl_session_timeout 5m;

ssl_ciphers HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on;
error_page 497 301 https://$http_host$request_uri;

location / {
root E:/xxxxxxxxxx/frontend/admin-dist/dist;
#root E:/indextest;
index index.html index.htm;
try_files $uri $uri/ /index.html;

proxy_set_header Host $host:$server_port;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-Host $http_host;
proxy_set_header X-Forwarded-Port $server_port;
proxy_redirect off;
}
}
# 设置http自动重定向到https
server {
listen 80;
server_name xxxx.xxxxx.com;
rewrite ^(.*)$ https://${server_name}$1 permanent;
}
}


举报

相关推荐

0 条评论