# Proxy to a .Net webservice

**URL:** <https://www.ruby-forum.com/t/proxy-to-a-net-webservice/188332>\
**Category:** NGINX\
**Created:** [May 10, 2010, 11:39am UTC](https://www.ruby-forum.com/t/proxy-to-a-net-webservice/188332 "2010-05-10T11:39:21Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![SSSSSSSSSSSSS\_SS](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/a3d4f5/32.png) [@SSSSSSSSSSSSS\_SS](https://www.ruby-forum.com/u/SSSSSSSSSSSSS_SS)\
**Post date:** [May 10, 2010, 11:39am UTC](https://www.ruby-forum.com/t/proxy-to-a-net-webservice/188332/1 "2010-05-10T11:39:21Z")

</div>

Hi,

Company is testing nginx with a .net SOAP web service. The nginx and web  
service runs on two different ports. The problem is the web service  
returns the response with links that point to the web service’s own TCP  
port instead of the port of the Nginx.

Here is the config being used:

// …

server  
{  
listen 89;  
server\_name mysolr;

```
location / {
    proxy_pass http://mysolr/;
    proxy_redirect off;
    proxy_set_header Host $host:$server_port;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header REMOTE-HOST $remote_addr;
    proxy_set_header X-Forwarded-For $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}

```

}

In the above case, response comes back with all embedded links on port  
80 rather than on 89.

Any help is appreciated~

Bing

---

<div class="post-metadata">

**Author:** ![SSSSSSSSSSSSS\_SS](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/a3d4f5/32.png) [@SSSSSSSSSSSSS\_SS](https://www.ruby-forum.com/u/SSSSSSSSSSSSS_SS)\
**Post date:** [May 11, 2010, 6:02am UTC](https://www.ruby-forum.com/t/proxy-to-a-net-webservice/188332/2 "2010-05-11T06:02:57Z")

</div>

Anyone please?

From: å†‰å…µ  
Sent: Monday, May 10, 2010 5:37 PM  
To: removed\_email\_address@domain.invalid  
Subject: proxy to a .Net webservice

Hi,

Company is testing nginx with a .net SOAP web service. The nginx and web  
service runs on two different ports. The problem is the web service  
returns the response with links that point to the web service’s own TCP  
port instead of the port of the Nginx, i.e., the web service server does  
not realize that requests come via a proxy on a different port.

Here is the config being used:

// …

server  
{  
listen 89;  
server\_name mysolr;

```
location / {
    proxy_pass http://mysolr/;
    proxy_redirect off;
    proxy_set_header Host $host:$server_port;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header REMOTE-HOST $remote_addr;
    proxy_set_header X-Forwarded-For $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}

```

}

In the above case, response comes back with all embedded links on port  
80 rather than on 89.

Any help is appreciated~

Bing

---

<div class="post-metadata">

**Author:** ![SSSSSSSSSSSSS\_SS](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/a3d4f5/32.png) [@SSSSSSSSSSSSS\_SS](https://www.ruby-forum.com/u/SSSSSSSSSSSSS_SS)\
**Post date:** [May 11, 2010, 9:43am UTC](https://www.ruby-forum.com/t/proxy-to-a-net-webservice/188332/3 "2010-05-11T09:43:03Z")

</div>

On Mon, May 10, 2010 at 05:37:58PM +0800, å†‰å…µ wrote:

> ```
> listen 89;
> server_name mysolr;
> 
> location / {
> proxy_pass http://mysolr/;
> proxy_redirect off;
> proxy_set_header Host $host:$server_port;
> proxy_set_header X-Real-IP $remote_addr;
> proxy_set_header REMOTE-HOST $remote_addr;
> proxy_set_header X-Forwarded-For $remote_addr;
> proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
> 
> ```

Why do use so many header with remote address ?  
BTW, the last X-Forwarded-For overrides the previous one.

> ```
> }
> 
> ```
> 
> }
> 
> In the above case, response comes back with all embedded links on port 80 rather than on 89.

You may try to set webservice to listen on 127.0.0.1:80 and set nginx  
to listen on mysolr:80.

Also you may use

```
   sub_filter http://mysolr:80/ http://mysolr:89/;
   sub_filter_once off;

```

–  
Igor S.

> **[Igor Sysoev](http://sysoev.ru/en/)**

---

<div class="post-metadata">

**Author:** ![SSSSSSSSSSSSS\_SS](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/a3d4f5/32.png) [@SSSSSSSSSSSSS\_SS](https://www.ruby-forum.com/u/SSSSSSSSSSSSS_SS)\
**Post date:** [October 17, 2011, 1:48pm UTC](https://www.ruby-forum.com/t/proxy-to-a-net-webservice/188332/4 "2011-10-17T13:48:55Z")

</div>

Dear 冉兵,

I face the same problem as yours, please could you show me  
configurations which worked for you?

Thanks

Posted at Nginx Forum:

> **[Re: proxy to a .Net webservice](https://forum.nginx.org/read.php?2,84720,216823#msg-216823)**
>
> Hi, Company is testing nginx with a .net SOAP web service. The nginx and web service runs on two different ports. The problem is the web service returns the response with links that point to the web service's own TCP port instead of the port of the...

---

<div class="post-metadata">

**Author:** ![SSSSSSSSSSSSS\_SS](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/a3d4f5/32.png) [@SSSSSSSSSSSSS\_SS](https://www.ruby-forum.com/u/SSSSSSSSSSSSS_SS)\
**Post date:** [May 11, 2010, 12:24pm UTC](https://www.ruby-forum.com/t/proxy-to-a-net-webservice/188332/5 "2010-05-11T12:24:02Z")

</div>

Hi,

The sub\_filter way worked.

Thanks

Bing

* * *

From: “Igor S.” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
Sent: Tuesday, May 11, 2010 3:42 PM  
To: [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
Subject: Re: proxy to a .Net webservice
