nginx跨域问题
来源:3-9 Nginx作为静态资源web服务_跨域访问场景配置
dessler123
2017-07-27
server {listen 443;ssl 设置部分省略 server_name abc.com;location /123 { proxy_pass http://123; proxy_set_header Host $host:$server_port; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; }location /xyz { proxy_pass http://xyz; proxy_set_header Host $host:$server_port; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; }location /abc { proxy_pass http://abc; proxy_set_header Host $host:$server_port; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; }
upstream 123 { server 192.168.3.210:83 max_fails=1 fail_timeout=60s; }upstream xyz { server 192.168.3.210:84 max_fails=1 fail_timeout=60s; }upstream abc { server 192.168.3.210:8084 max_fails=1 fail_timeout=60s; }
访问 https://abc.com/123 和https://abc.com/xyz 均会调用 http://abc.com/abc的内容
但是https调用http的均有跨域的问题 应该如何解决
写回答
1回答
-
Jeson
2017-07-27
你得意思是不是对外服务用的同一个域名,只是服务自己调用自己。如果这样的话,location /abc{}这级中添加跨域规则Access-Control-Allow-Origin。
00
相似问题