# Problem with http headers when using ssl

**URL:** <https://www.ruby-forum.com/t/problem-with-http-headers-when-using-ssl/221501>\
**Category:** NGINX\
**Created:** [July 17, 2012, 3:26pm UTC](https://www.ruby-forum.com/t/problem-with-http-headers-when-using-ssl/221501 "2012-07-17T15:26:33Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![aris](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/258eb7/32.png) [@aris](https://www.ruby-forum.com/u/aris)\
**Post date:** [July 17, 2012, 3:26pm UTC](https://www.ruby-forum.com/t/problem-with-http-headers-when-using-ssl/221501/1 "2012-07-17T15:26:33Z")

</div>

Hi everyone,

when i’m proxying to tomcat server everything is fine, proxy\_pass works.  
From there i connect to some payment site, but if i decide to go back,  
it brings me to to site:

[https://www80/actionVaiisisPayment.action](https://www80/actionVaiisisPayment.action)

but it should be ip adress not upstream name:

[https://10.255.7.120:8080/actionVaiisisPayment.action](https://10.255.7.120:8080/actionVaiisisPayment.action)

Here’s part of my nginx.conf file:

http {  
upstream www80 {  
server 10.255.7.120:8080;  
}  
upstream www443 {  
server 10.255.7.120:443;  
}

server {  
#server\_name alis.am.lt;  
#server\_name\_in\_redirect off;  
listen 443;  
ssl on;  
ssl\_certificate /home/dts/certificates/alis.am.lt.pem;  
ssl\_certificate\_key  
/home/dts/certificates/alis.am.lt\_privateKeyNoPass.key;  
ssl\_ciphers HIGH:!aNULL:!MD5:!kEDH;  
keepalive\_timeout 70;

```
  location / {
    proxy_pass http://www80;
    proxy_redirect default;
    proxy_set_header X-Forwarded-Host $host;
    proxy_set_header X-Forwarded-Server $host;
    proxy_set_header X-Forwarded-For

```

$proxy\_add\_x\_forwarded\_for;  
proxy\_set\_header X-Forwarded-Ssl on;  
proxy\_set\_header X-Forwarded-Proto https;  
}

Can anyone help me, please? Thanks in advance.

Regards,  
Karolis

Posted at Nginx Forum:

> **[problem with http headers when using ssl](https://forum.nginx.org/read.php?2,228638,228638#msg-228638)**
>
> Hi everyone, when i'm proxying to tomcat server everything is fine, proxy\_pass works. From there i connect to some payment site, but if i decide to go back, it brings me to to site: https://www80/actionVaiisisPayment.action but it should be ip adress...

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [July 17, 2012, 3:45pm UTC](https://www.ruby-forum.com/t/problem-with-http-headers-when-using-ssl/221501/2 "2012-07-17T15:45:51Z")

</div>

> when i’m proxying to tomcat server everything is fine, proxy\_pass works.  
> From there i connect to some payment site, but if i decide to go back,  
> it brings me to to site:  
> [https://www80/actionVaiisisPayment.action](https://www80/actionVaiisisPayment.action)  
> but it should be ip adress not upstream name:  
> [https://10.255.7.120:8080/actionVaiisisPayment.action](https://10.255.7.120:8080/actionVaiisisPayment.action)

The www80 probably comes from the upstream application (which makes a  
redirect) since you don’t pass the real Host: header back to upstream  
and  
nginx uses the ‘www80’ upstream name when connecting to the backend.

You can either try to pass the actuall Host: header back to upstream -  
add:

proxy\_set\_header Host $host;

Or you can change the redirects with proxy\_redirect (  
[GitHub - nginxinc/nginx-wiki: ARCHIVED -- Source for the now archived NGINX Wiki section of https://www.nginx.com · GitHub](http://wiki.nginx.org/NginxHttpProxyModule#proxy_redirect) )

rr

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [July 17, 2012, 4:09pm UTC](https://www.ruby-forum.com/t/problem-with-http-headers-when-using-ssl/221501/3 "2012-07-17T16:09:49Z")

</div>

Actually when i insert into my configuration this line  
proxy\_set\_header Host $host;  
i can’t access site at all. I tried every configuration with  
proxy\_redirect, still no results… ☹  
Any more suggestions?

Posted at Nginx Forum:

> **[Re: problem with http headers when using ssl](https://forum.nginx.org/read.php?2,228638,228643#msg-228643)**
>
> Hi everyone, when i'm proxying to tomcat server everything is fine, proxy\_pass works. From there i connect to some payment site, but if i decide to go back, it brings me to to site: https://www80/actionVaiisisPayment.action but it should be ip adress...
