救赎之旅- 2021-09-22 13:12 采纳率: 71.4%
浏览 40

使用nginx反向代理网站时 , 网站加载报错

反向代理成功后 , 网站可以进去 , 但是初始化加载时报错 , 执行ajax请求时报错 , nginx配置如下 :
server {
listen 8010;
server_name 192.168.2.105;

        #location / {
        #    root   html;
        #    index  index.html index.htm;
        #}
        
        location / {
            proxy_pass http://192.168.2.105:820;
            proxy_redirect default;
            proxy_set_header Host  $http_host;
            proxy_set_header Cookie $http_cookie;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header X-Forwarded-Proto $scheme;
            add_header 'Access-Control-Allow-Origin' '*';  
            add_header 'Access-Control-Allow-Credentials' 'true';  
            client_max_body_size  100m;
            proxy_connect_timeout       1;
        }
    
        location /TianChen/ {
            rewrite  ^.+TianChen/?(.*)$ /$1 break; 
            include  uwsgi_params;
            proxy_pass http://192.168.2.143:808/;
            proxy_set_header Host  $http_host;
            proxy_set_header Cookie $http_cookie;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header X-Forwarded-Proto $scheme;
            add_header 'Access-Control-Allow-Origin' '*';  
            add_header 'Access-Control-Allow-Credentials' 'true';  
            client_max_body_size  100m;
            proxy_connect_timeout       1;
        }
        
        location ~.*\.(html|js|css|map|gif|png|jpg|woff|woff2|ico)$ {
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            add_header Access-Control-Allow-Origin $http_origin;
            add_header Access-Control-Allow-Headers X-Requested-With;
            add_header Access-Control-Allow-Methods GET,POST,OPTIONS;
            proxy_pass http://192.168.2.143:808;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header Host $host;
            sub_filter <head> '<head> <meta name="referrer" content="no-referrer" />';
        }

报错图 :

img

img

  • 写回答

3条回答 默认 最新

  • 救赎之旅- 2021-09-22 13:13
    关注

    img

    评论

报告相同问题?

问题事件

  • 创建了问题 9月22日

悬赏问题

  • ¥15 电力市场出清matlab yalmip kkt 双层优化问题
  • ¥30 ros小车路径规划实现不了,如何解决?(操作系统-ubuntu)
  • ¥20 matlab yalmip kkt 双层优化问题
  • ¥15 如何在3D高斯飞溅的渲染的场景中获得一个可控的旋转物体
  • ¥88 实在没有想法,需要个思路
  • ¥15 MATLAB报错输入参数太多
  • ¥15 python中合并修改日期相同的CSV文件并按照修改日期的名字命名文件
  • ¥15 有赏,i卡绘世画不出
  • ¥15 如何用stata画出文献中常见的安慰剂检验图
  • ¥15 c语言链表结构体数据插入