Solve the soap:address location problem of nginx response Proxy Web Service

Source: Internet
Author: User
Tags nginx reverse proxy
One: first to publish a Web service

Package Com.ws.service;public Interface Iuserservice{public string GetUserName (string id);}
Package Com.ws.service;import Javax.jws.webmethod;import Javax.jws.webparam;import javax.jws.webservice;@ Webservicepublic class UserService implements iuserservice{@WebMethodpublic String getusername (@WebParam (name= "id") String ID) {return "User:" + ID;}}
Package Com.ws.service;import Javax.xml.ws.endpoint;public class Server{public static void Main (string[] args) { Endpoint.publish ("Http://0.0.0.0:6633/api/v1/user", New UserService ()); System.out.println ("WS Startup OK on port" + 6633);}}

The port for WS is 6633

Access address is: HTTP://192.168.100.95:6633/API/V1/USER?WSDL


Then, the Nginx configuration is as follows:

Upstream WebService {server 192.168.10.95:6633;} server {    listen       6633;    Location/{Proxy_pass http://webservice;}}

The Nginx address is: 192.168.2.123

Then Access Proxy address: http://192.168.2.123:6633/api/v1/user?wsdl

The results are as follows


The address here is obviously wrong.

Here's how to fix it

The Nginx configuration changes to:

Upstream WebService {server 192.168.100.95:6633;} server {    listen       6633;    Location/{                Proxy_set_header Host $host: $server _port;proxy_pass http://webservice;}}

The reason is that if there is no configuration
Proxy_set_header Host $host: $server _port;
Then, Nginx reverse proxy to the background, pass the host HTTP header for

Host=webservice

The above describes the solution of the Nginx Response Agent Web Service soap:address location problem, including the content, I hope that the PHP tutorial interested in a friend helpful.

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.