server {
listen 80;
server_name 127.0.0.1;
access_log /var/log/nginx/survey_access.log;
error_log /var/log/nginx/survey_error.log;
location /public/ {
root /home/kevin/nodeSrc/expressSrc/surveyProject;
}
location / {
proxy_pass http://127.0.0.1:3000;
}
}
訪問首頁127.0.0.1 能成功顯示,但在首頁有個自動的ajax請求是127.0.0.1/JS_GetPage_Record 這個請求一直502,不通過nginx反代都正常如果手動去點按鈕觸發這個按鈕返回是正常的
以下為解決方法
html
$('#tbl_list_index').bootstrapTable({
url: '/JS_GetPage_Record',
method: 'post',
contentType: "application/x-www-form-urlencoded",
striped: true,
cache: false,
pagination: true,
sortable: false,
sortOrder: "asc",
queryParams: function (params) {
return {
pageSize: params.limit,
pageIndex: params.offset
}
},
sidePagination: "server",
pageNumber: 1,
pageSize: 30,
pageList: [30, 40, 50, 100],
strictSearch: true,
clickToSelect: true,
//height: 600,
uniqueId: "Id",
cardView: false,
detailView: false,
smartDisplay: false,
columns: [...] //省略
});
這是html裡ajax打開首頁自動請求的語句,查看訊息 X-Powered-By:nginx1.6.2 一看就是還沒到express裡面,所以nginx配置加上,成功請求!
location /JS_GetPage_Record {
proxy_pass http://127.0.0.1:3000/JS_GetPage_Record;
}
但是不理解為何,主動請求nginx不繼續往下請求,難道每個自動請求都要寫入nginx配置?
今天一測 又不好使了
直接訪問 http://127.0.0.1/JS_GetPage_Record 出來什麼