反向代理成功后 , 网站可以进去 , 但是初始化加载时报错 , 执行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" />';
}
报错图 :
rootpath是什么
获取的当前的网址, 所以地址不对,现在是2.105:8010 应该为1.143:808才对
这个能配置代理转发之类的吗
现在是把1.143:808的系统在nginx上做了一个代理,用户通过1.105:8010访问
@救赎之旅-: 你这个配置,应该是访问8010,实际转发到808和820吧?
@救赎之旅-: 这是你想要的?你rootpath()得到的是什么?
你应该是访问 http(s)://your nginx ip:port/your context-path