由于有的公司不是所有服务器可以连接外网,只有dmz区域的服务器可以连接,所以我在部署服务的时候,以这台服务器作为代理,来代替内网发送请求进行访问,请求的url是:curl "http://cde.com/aiapi" ,但是出现一个问题,就是在发送的请求外网访问正常,但是内网服务器通过代理请求的时候有时候是200,有时候是503或404,想求大神解答这是什么原因?
附上ha proxy.cnf配置文件:
#
# demo config for Proxy mode
#
global
maxconn 50000
log 127.0.0.1 local3 info #notice #info
uid 200
gid 200
chroot /var/empty
nbproc 4
daemon
defaults
option redispatch
retries 3
maxconn 50000
timeout connect 50000s
timeout client 50000s
timeout server 50000s
frontend mqtt
bind *:1884
bind *:1885
bind *:843
bind *:1883
mode tcp
option tcplog
log global
default_backend mqtt_ap
frontend web
bind *:80
bind *:443
mode http
log global
option httplog
option forwardfor
acl robot_static path_reg -i ^/aiapi
acl fd_syn hdr(host) -i abc.com
acl xbot_req hdr(host) -I cde.com
use_backend xbot_ask if robot_static
use_backend yum_php if fd_syn
use_backend xbot_ask if xbot_req
default_backend yum_php
backend yum_php
mode http
option httplog
option tcp-check
server yum1 1.2.3.4:80 check inter 2000 rise 1 fall 10
backend xbot_ask
mode http
option httplog
server xbot 5.6.7.8:80listen status
bind-process 1
bind *:9088
stats enable
mode http
timeout client 30s
stats hide-version
stats uri /admin?status
stats auth admin:wb1823!@3
stats realm (Haproxy\ statistic)
stats refresh 30s
附上ha proxy.cnf配置文件:
#
# demo config for Proxy mode
#
global
maxconn 50000
log 127.0.0.1 local3 info #notice #info
uid 200
gid 200
chroot /var/empty
nbproc 4
daemon
defaults
option redispatch
retries 3
maxconn 50000
timeout connect 50000s
timeout client 50000s
timeout server 50000s
frontend mqtt
bind *:1884
bind *:1885
bind *:843
bind *:1883
mode tcp
option tcplog
log global
default_backend mqtt_ap
frontend web
bind *:80
bind *:443
mode http
log global
option httplog
option forwardfor
acl robot_static path_reg -i ^/aiapi
acl fd_syn hdr(host) -i abc.com
acl xbot_req hdr(host) -I cde.com
use_backend xbot_ask if robot_static
use_backend yum_php if fd_syn
use_backend xbot_ask if xbot_req
default_backend yum_php
backend yum_php
mode http
option httplog
option tcp-check
server yum1 1.2.3.4:80 check inter 2000 rise 1 fall 10
backend xbot_ask
mode http
option httplog
server xbot 5.6.7.8:80listen status
bind-process 1
bind *:9088
stats enable
mode http
timeout client 30s
stats hide-version
stats uri /admin?status
stats auth admin:wb1823!@3
stats realm (Haproxy\ statistic)
stats refresh 30s
用nginx吧
跟一下日志,看看访问ip是不是同一个,这种情况在NAT转发或者路由器网关模式比较常见