Nginx supports cross-origin access and nginx cross-origin access
1. Enter the nginx html directory.
Vim./crossdomain. xml
Path:/usr/local/nginx/html/crossdomain. xml
2. Add the following in crossdomain. xml:
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE cross-domain-policy SYSTEM "http://www.adobe.com/xml/dtds/cross-domain-policy.dtd"><cross-domain-policy><allow-access-from domain="*" /></cross-domain-policy>
The result is:
Note:/usr/local/nginx/html/crossdomain. xml does not exist by default.
Forward requests through nginx
Modify:/usr/local/etc/nginx/vhosts/xx.com. conf
server { listen 80; server_name xxx.com 10.1.146.81; location / {add_header 'Access-Control-Allow-Origin' '*';add_header 'Access-Control-Allow-Credentials' 'true';add_header 'Access-Control-Allow-Methods' '*'; proxy_pass http://localhost:8088; # proxy_redirect off ; index index.php index.html index.htm; }# error_page 500 502 503 504 /50x.html;}