server {
listen 443 ssl;
listen 80;
server_name aaa.myproxy.net;#nginx代理服务器域名
index index.html index.php;
ssl_certificate /data/server/conf/cert/aaa.myproxy.net.pem;
ssl_certificate_key /data/server/conf/cert/aaa.myproxy.net.key;
ssl_session_timeout 5m;
ssl_protocols TLSv1.2 TLSv1.1 TLSv1;
ssl_ciphers AESGCM:ALL:!DH:!EXPORT:!RC4:+HIGH:!MEDIUM:!LOW:!aNULL:!eNULL;
ssl_prefer_server_ciphers off;
location / {
proxy_pass https://bbb.service.com;#反向代理,真正请求资源的服务器地址
proxy_cookie_domain bbb.service.com client.domain.com;#修改cookie里域名
add_header Access-Control-Allow-Origin http://client.domain.com;#当前端只跨域不带cookie时,可为*
add_header Access-Control-Allow-Credentials true;
}
#access_log /alidata/logs/nginx/access/aaa.log;#关闭access日志
}
用法:
1.假设:web页面的访问域名为“https://client.domain.com”,页面访问协议要与代理服务器协议一致,即,页面的访问域名为https,代理服务器域名也要配置为https
2.web页面所有发向“bbb.service.com”域名的请求,统一修改为发向“aaa.myproxy.net”