nginx添加证书反向代理

upstream bkend {
server 127.0.0.1:8080 weight=1 max_fails=3 fail_timeout=30s;
}

server {
listen 80;
listen 443 ssl http2;
server_name xxxxxxx.cn,;
error_log /var/log/nginx/jkhuimin.cn_error.log;
access_log /var/log/nginx/jkhuimin.cn_access.log;
ssl_certificate /etc/nginx/cert/1759163_jkhuimin.cn.pem;
ssl_certificate_key /etc/nginx/cert/1759163_jkhuimin.cn.key;
if ($ssl_protocol = "") { rewrite ^ https://$host/$uri permanent; }
location / {
if ($request_method = OPTIONS ) { return 200; }
add_header Access-Control-Allow-Origin $http_origin;
add_header Access-Control-Allow-Methods GET,POST,PUT,OPTIONS,DELETE,PATCH;
add_header Access-Control-Allow-Credentials true;
add_header Access-Control-Allow-Headers DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Content-Range,Range,userId,token,vcode;
add_header Access-Control-Max-Age 1728000;

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://bkend;
}
client_max_body_size 512M;
}

 

posted @ 2019-01-29 13:51  Rayja-gyeong  阅读(202)  评论(0)    收藏  举报