Groups
Groups
Sign in
Groups
Groups
openresty
Conversations
Labels
About
Send feedback
Help
openresty配置反向代理配置搞不定了,求教!
120 views
Skip to first unread message
泡泡龙
unread,
Mar 27, 2016, 5:16:11 AM
3/27/16
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to openresty
hi,各位大神好:
我配置了一个openresty做虚拟主机,将域名
a.abc.com
指向他,然后通过反向代理指向另外一台做服务的openresy上,地址为内网
http://192.168.1.100:8050/
配置如下:
location / {
proxy_pass
http://192.168.1.100:8050/
;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header REMOTE-HOST $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
在这个
192.168.1.100:8050
服务器上,我安装了一个WordPress服务程序,目录为
http://192.168.1.100:8050/WordPress
8050的服务器配置如下
location / {
root html;
index index.html index.htm index.php;
}
location ~ \.php$ {
root html;
fastcgi_pass
127.0.0.1:9000
;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /data/bin/openresty8050/nginx/html/$fastcgi_script_name;
include fastcgi_params; }
现在的问题是,如果使用
http://192.168.1.100:8050/WordPress
访问,没有问题
使用
a.abc.com
访问,也可以看到 html目录下的phpinfo
但是如果使用
http://a.abc.com/WordPress
访问,地址再浏览器地址栏就会变为
http://a.abc.com:8050/WordPress
然后访问出错
急求大神帮助,折磨我一天一夜了。。。。。各种百度各种试,还是搞不定。。。。
Yichun Zhang (agentzh)
unread,
Mar 27, 2016, 3:30:50 PM
3/27/16
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to openresty
Hello!
2016-03-27 2:16 GMT-07:00 泡泡龙:
> location / {
> proxy_pass
http://192.168.1.100:8050/
;
你这里一个明显的错误是不该在 proxy_pass 的末尾使用 /.
> 使用
a.abc.com
访问,也可以看到 html目录下的phpinfo
>
> 但是如果使用
http://a.abc.com/WordPress
访问,地址再浏览器地址栏就会变为
>
http://a.abc.com:8050/WordPress
>
> 然后访问出错
也许你的后端 php 应用会发起含有硬编码主机名的 301/302 跳转?建议你在 HTTP
的层面上分析实际发生的请求和响应。当然,你得先修了上面那个明显的错误再说。
Regards,
-agentzh
Guanglin Lv
unread,
Mar 27, 2016, 9:51:19 PM
3/27/16
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to openresty, 2394...@qq.com
春哥说的很对,很大可能是你后端应用的配合问题;
我以前也遇到过,当时后端服务器是WAS(Websphere Application Server),它在产生302响应时,location里会填上自己的服务端口。若前面有反向代理,反向代理在转发请求时需要显示加上一个WSSP的头域标识出服务端口。这样后面服务器跳转才不会有问题;
在 2016年3月27日星期日 UTC+8下午5:16:11,泡泡龙写道:
Reply all
Reply to author
Forward
0 new messages