账号密码登录
微信安全登录
微信扫描二维码登录

登录后绑定QQ、微信即可实现信息互通

手机验证码登录
找回密码返回
邮箱找回 手机找回
注册账号返回
其他登录方式
分享
  • 收藏
    X
    nginx跨域conf配置不起作用
    42
    0
    server {
            listen       80;
            server_name  daidu.com;
        
        add_header 'Access-Control-Allow-Origin' *;
            #charset koi8-r;
    
            #access_log  logs/host.access.log  main;
        
        location /myindex {
                proxy_pass   https://xmjg.mulifang.net/WXInTerFace/myindex;
            }
            location / {
                root   www;
                index  index.html index.htm;
            }
        
        
    
            #error_page  404              /404.html;
    
            # redirect server error pages to the static page /50x.html
            #
            error_page   500 502 503 504  /50x.html;
            location = /50x.html {
                root   html;
            }
    
            # proxy the PHP scripts to Apache listening on 127.0.0.1:80
            #
            #location ~ \.php$ {
            #    proxy_pass   http://127.0.0.1;
            #}
    
            # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
            #
            #location ~ \.php$ {
            #    root           html;
            #    fastcgi_pass   127.0.0.1:9000;
            #    fastcgi_index  index.php;
            #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
            #    include        fastcgi_params;
            #}
    
            # deny access to .htaccess files, if Apache's document root
            # concurs with nginx's one
            #
            #location ~ /\.ht {
            #    deny  all;
            #}
        }
    0
    打赏
    收藏
    点击回答
    您的回答被采纳后将获得:提问者悬赏的 10 元积分
        全部回答
    • 0
    • 跨域配置不生效的原因可能有以下几点:

      1. Nginx没有配置正确的CORS(跨源资源共享)头部。在配置文件中,需要添加以下配置:

      nginx server { listen 80; server_name example.com; location / { try_files $uri $uri/ /index.php?$args; } }

      1. Nginx服务器没有正确配置CORS头部。在配置文件中,需要添加以下配置:

      nginx server { listen 80; server_name example.com; add_header Access-Control-Allow-Origin *; add_header Access-Control-Allow-Methods GET, POST, PUT, DELETE; add_header Access-Control-Allow-Headers "Content-Type,Authorization"; }

      1. Nginx服务器的CORS策略不正确。在配置文件中,需要添加以下配置:

      nginx server { listen 80; server_name example.com; location / { add_header Access-Control-Allow-Origin *; add_header Access-Control-Allow-Methods GET, POST, PUT, DELETE; add_header Access-Control-Allow-Headers "Content-Type,Authorization"; allow all; } }

      1. Nginx服务器没有正确配置CORS头。在配置文件中,需要添加以下配置:

      nginx server { listen 80; server_name example.com; location / { try_files $uri $uri/ /index.php?$args; add_header Access-Control-Allow-Origin *; add_header Access-Control-Allow-Methods GET, POST, PUT, DELETE; add_header Access-Control-Allow-Headers "Content-Type,Authorization"; allow all; } }

      请检查以上配置,确保没有遗漏。如果问题仍然存在,可能需要检查你的服务器配置,例如设置正确的Nginx版本和防火墙规则。

    更多回答
    扫一扫访问手机版
    • 回到顶部
    • 回到顶部