nginx forwarding webService interface problem record

Since the company has recently created a new test environment, it needs to deploy an execution machine in it. However, the network is not connected to the previous environment. It needs to use nginx proxy forwarding. I encountered some problems along the way and recorded them here.

1.nginx configuration problem

server{
        listen 8080;
        location / {
             proxy_pass http://ip:port;
             proxy_set_header Host ip:port; #必配,否则导致Location问题
        }
}

2.webService proxy problem

After configuring nginx, the code keeps reporting errors: HTTP transmission error: java.net.ConnectException: Connection timed out

However, it was normal to access the webService interface in the browser and call it in Postman. It took two days to solve the problem. When using a proxy, you need to bind the remote calling interface when implementing the interface.

String wsdlURL = "xxxx"; //要请求的URL地址 
...
MyService myService = serviceWebClient.getPort(MyService.class);
BindingProvider bindingProvider = (BindingProvider) myService;
bindingProvider.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, wsdlURL);

Reference article: Http transmission error problem of webservice - take a look (zoukankan.com)

postman tests the WebService interface_Xiaodou's programming world...'s blog-CSDN blog_postman tests the webservice interface

Guess you like

Origin blog.csdn.net/y954227239/article/details/127285348