Problem with http headers when using ssl

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 not upstream name:

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:

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 not upstream name:
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 (
Module ngx_http_proxy_module )

rr

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… :frowning:
Any more suggestions?

Posted at Nginx Forum: