# Ssl on different servers

**URL:** <https://www.ruby-forum.com/t/ssl-on-different-servers/236770>\
**Category:** NGINX\
**Created:** [October 2, 2013, 3:19am UTC](https://www.ruby-forum.com/t/ssl-on-different-servers/236770 "2013-10-02T03:19:12Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![alcina](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/a587f6/32.png) [@alcina](https://www.ruby-forum.com/u/alcina)\
**Post date:** [October 2, 2013, 3:19am UTC](https://www.ruby-forum.com/t/ssl-on-different-servers/236770/1 "2013-10-02T03:19:12Z")

</div>

Hi,  
My [domain.com](http://domain.com) is on ip: x.x.x.x  
where I have a configuration like:

server {  
server\_name [sub.domain.com](http://sub.domain.com);  
location / {

```
  proxy_pass http://y.y.y.y;

  proxy_set_header X-Real-IP $remote_addr;
  proxy_set_header Host $host;
  proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}

```

On ip y.y.y.y my configuration is:

server {  
server\_name [sub.domain.com](http://sub.domain.com);  
location / {

```
  proxy_pass http://localhost:8080;

  proxy_set_header X-Real-IP $remote_addr;
  proxy_set_header Host $host;
  proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}

```

That’s fine!

But…

I’m trying to add ssl support, I bought a wildcard certificate but  
unfortunately I’m struggling with the configuration.

I changed the config on x.x.x.x:

server {  
server\_name [sub.domain.com](http://sub.domain.com);  
location / {  
proxy\_pass [http://y.y.y.y](http://y.y.y.y);

```
  proxy_set_header X-Forwarded-Proto https;

  proxy_set_header X-Real-IP $remote_addr;
  proxy_set_header Host $host;
  proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}

```

listen 443;  
ssl\_certificate ssl.crt;  
ssl\_certificate\_key my.key;  
}

and I changed the config on y.y.y.y:

server {  
server\_name [sub.domain.com](http://sub.domain.com);  
location / {  
proxy\_pass [http://localhost:8080](http://localhost:8080);  
proxy\_set\_header X-Real-IP $remote\_addr;  
proxy\_set\_header Host $host;  
proxy\_set\_header X-Forwarded-For $proxy\_add\_x\_forwarded\_for;  
}

```
   listen 443 ssl;
   ssl_certificate ssl.crt;
   ssl_certificate_key my.key;

```

}

I also tried other configuration, but I cannot make it working.

Can you help me, please?

Thanks

Dossi

Posted at Nginx Forum:

> **[ssl on different servers](https://forum.nginx.org/read.php?2,243340,243340#msg-243340)**
>
> Hi, My domain.com is on ip: x.x.x.x where I have a configuration like: server { server\_name sub.domain.com; location / { proxy\_pass http://y.y.y.y; proxy\_set\_header X-Real-IP $remote\_addr;

---

<div class="post-metadata">

**Author:** ![dossi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/e0b2c6/32.png) [@dossi](https://www.ruby-forum.com/u/dossi)\
**Post date:** [October 2, 2013, 6:26am UTC](https://www.ruby-forum.com/t/ssl-on-different-servers/236770/2 "2013-10-02T06:26:11Z")

</div>

what is your problem then?

Posted at Nginx Forum:

> **[Re: ssl on different servers](https://forum.nginx.org/read.php?2,243340,243342#msg-243342)**
>
> Hi, My domain.com is on ip: x.x.x.x where I have a configuration like: server { server\_name sub.domain.com; location / { proxy\_pass http://y.y.y.y; proxy\_set\_header X-Real-IP $remote\_addr;

---

<div class="post-metadata">

**Author:** ![dossi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/e0b2c6/32.png) [@dossi](https://www.ruby-forum.com/u/dossi)\
**Post date:** [October 2, 2013, 9:07am UTC](https://www.ruby-forum.com/t/ssl-on-different-servers/236770/3 "2013-10-02T09:07:30Z")

</div>

The problem is that if I point a browser to [https://sub.domain.com](https://sub.domain.com) it  
doesn’t work.

Cheers  
Dossi

Posted at Nginx Forum:

> **[Re: ssl on different servers](https://forum.nginx.org/read.php?2,243340,243352#msg-243352)**
>
> Hi, My domain.com is on ip: x.x.x.x where I have a configuration like: server { server\_name sub.domain.com; location / { proxy\_pass http://y.y.y.y; proxy\_set\_header X-Real-IP $remote\_addr;

---

<div class="post-metadata">

**Author:** ![dossi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/e0b2c6/32.png) [@dossi](https://www.ruby-forum.com/u/dossi)\
**Post date:** [October 2, 2013, 9:11am UTC](https://www.ruby-forum.com/t/ssl-on-different-servers/236770/4 "2013-10-02T09:11:35Z")

</div>

did you tried to turn it off and on again?

sorry, but from your description no one would be able to help you.

regards,

mex

Posted at Nginx Forum:

> **[Re: ssl on different servers](https://forum.nginx.org/read.php?2,243340,243353#msg-243353)**
>
> Hi, My domain.com is on ip: x.x.x.x where I have a configuration like: server { server\_name sub.domain.com; location / { proxy\_pass http://y.y.y.y; proxy\_set\_header X-Real-IP $remote\_addr;

---

<div class="post-metadata">

**Author:** ![dossi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/e0b2c6/32.png) [@dossi](https://www.ruby-forum.com/u/dossi)\
**Post date:** [October 2, 2013, 9:32am UTC](https://www.ruby-forum.com/t/ssl-on-different-servers/236770/5 "2013-10-02T09:32:38Z")

</div>

What’s not working, I suppose, is that the client browser go to  
[https://sub.domain.com](https://sub.domain.com) (on IP x.x.x.x) that it is forwarded to IP  
y.y.y.y

Is there any link that explains how to configure that two nginxes (one  
on  
x.x.x.x and one on y.y.y.y) so that the https traffic “routes” from  
x.x.x.x  
to y.y.y.y?

I found these two posts:

> <https://stackoverflow.com/questions/2958650/how-to-add-ssl-to-subdomain-that-points-to-a-different-server>

[http://danconnor.com/post/4f65ea41daac4ed031000004/https\_ssl\_proxying\_nginx\_to\_nginx](http://danconnor.com/post/4f65ea41daac4ed031000004/https_ssl_proxying_nginx_to_nginx)

but the first does not show how the configuration and the second is  
similar  
to my issue, but it involves a load balancer that is not my case.  
My problem is: [https://sub.domain.com](https://sub.domain.com) → x.x.x.x → y.y.y.y

Dossi

Posted at Nginx Forum:

> **[Re: ssl on different servers](https://forum.nginx.org/read.php?2,243340,243354#msg-243354)**
>
> Hi, My domain.com is on ip: x.x.x.x where I have a configuration like: server { server\_name sub.domain.com; location / { proxy\_pass http://y.y.y.y; proxy\_set\_header X-Real-IP $remote\_addr;

---

<div class="post-metadata">

**Author:** ![dossi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/e0b2c6/32.png) [@dossi](https://www.ruby-forum.com/u/dossi)\
**Post date:** [October 2, 2013, 10:05am UTC](https://www.ruby-forum.com/t/ssl-on-different-servers/236770/6 "2013-10-02T10:05:58Z")

</div>

Hi,

it sounds as if you want to proxy your ssl request to another server and  
terminate it there?! You cannot do this.

You need to establish a ssl connection first before you can use http/s.

regards,  
Axel

Am 02.10.2013 03:18, schrieb dossi:

---

<div class="post-metadata">

**Author:** ![dossi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/e0b2c6/32.png) [@dossi](https://www.ruby-forum.com/u/dossi)\
**Post date:** [October 2, 2013, 8:44pm UTC](https://www.ruby-forum.com/t/ssl-on-different-servers/236770/7 "2013-10-02T20:44:55Z")

</div>

On Wednesday 02 October 2013 05:18:22 you wrote:

> ```
> proxy_set_header X-Real-IP $remote_addr;
> proxy_pass http://localhost:8080;
> 
> ```
> 
> I’m trying to add ssl support, I bought a wildcard certificate but  
> unfortunately I’m struggling with the configuration.
> 
> I changed the config on x.x.x.x:
> 
> server {  
> server\_name [sub.domain.com](http://sub.domain.com);  
> location / {  
> proxy\_pass [http://y.y.y.y](http://y.y.y.y);  
> […]

You have changed y.y.y.y to use HTTPS, but still trying to pass HTTP.

wbr, Valentin V. Bartenev
