nginx配置问题,转发路径
1,我后台接口 地址是 http://127.0.0.1/d/{shortUrl}
因为我的后台和nginx 不在一个服务器要求是用户 访问nginx服务器 请求地址,http://abc.com/d/aqwdq 能转发到http://127.0.0.1/d/{shortUrl}
注意 {shortUrl}中的路径参数是不固定的
可以参考如下配置,注意短链服务器地址不能使用127.0.0.1(这个是本地回环地址,可以参考文章https://zhuanlan.zhihu.com/p/481549810),而是要使用和nginx服务器同局域网的IP(一般网段相同,windows可以使用控制台输入ipconfig,linux可以使用ifconfig查看)。
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
server {
listen 80;
location /d/ {
proxy_pass http://短链服务器IP:80;
}
}
}
在server里面配置
参考链接。希望有帮助哦
http://t.csdn.cn/H969J
nginx 不要配置 127.0.0.1 配置 后端服务器的实际内网ip 如果在一个局域网里面的话
麻烦贴下代码 能用的话就采纳了
提供参考实例【Nginx proxy_pass 配置转发 / 路径问题】:https://blog.csdn.net/lengyue1084/article/details/124426102
server {
listen 80;
server_name abc.com;
access_log logs/domain2.access.log main;
location /d {
# 这个ip地址替换为你的ip和端口号就可以了,但是你得保证nginx的机器通过浏览器或者curl能正常访问你的url
proxy_pass http://xx.xx.xx.xx:80;
}
}