数据接口是在网上抓取的https接口,项目部署时,请问nginx该如何配置?
目前Status Code: 200 OK,但页面不显示数据
listen 80 default_server;
listen [::]:80 default_server;
server_name _;
root /usr/share/nginx/html;
# Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf;
location / {
root /root/www/;
index index.html index.htm;
}
location /ajax/ {
proxy_set_header X-Real-IP $remote_addr;
proxy_pass https://****.com;
proxy_redirect off;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header X-NginX-Proxy true;
}
error_page 404 /404.html;
location = /404.html {
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
}
假设你的网上爬取数据接口地址为
https://www.data.com
项目
那么你在项目中只需要访问一个特定的
localtion
,比如项目直接ajax
url请求/data
,其实访问的就是http://localhost:port/data
nginx
你只需要在你对应的
serve
下配置代理即可,你需要代理/data