# Trouble getting SSL and proxying to work correctly

**URL:** <https://www.ruby-forum.com/t/trouble-getting-ssl-and-proxying-to-work-correctly/193582>\
**Category:** NGINX\
**Created:** [August 20, 2010, 1:37am UTC](https://www.ruby-forum.com/t/trouble-getting-ssl-and-proxying-to-work-correctly/193582 "2010-08-20T01:37:47Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![janine](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/85f322/32.png) [@janine](https://www.ruby-forum.com/u/janine)\
**Post date:** [August 20, 2010, 1:37am UTC](https://www.ruby-forum.com/t/trouble-getting-ssl-and-proxying-to-work-correctly/193582/1 "2010-08-20T01:37:47Z")

</div>

I have Googled and looked at various sample SSL configurations and it  
seems like I’ve got things set up right, but there are two problems I  
can’t seem to fix:

1. When I load [https://dev.mysite.com](https://dev.mysite.com), the lock that should appear in  
the upper right corner of the browser window does not appear.
2. The Java application behind the scenes uses httpUtil.GetRequestURL()  
to get the current request and it is getting [http://dev.mysite.com](http://dev.mysite.com)  
instead of [https://dev.mysite.com](https://dev.mysite.com).

I have tried setting the Host header to $host instead of $http\_host, and  
I’ve tried setting proxy\_redirect to set the URL to  
[https://dev.mysite.com](https://dev.mysite.com), but neither had any effect. Setting Host to  
[https://dev.mysite.com](https://dev.mysite.com) fixes the browser lock problem but appears to  
make the proxy\_pass redirect stop happening, as I get a nice secure  
blank page.

My SSL server config is below. Can someone please tell me what I’ve done  
wrong?

server {  
listen 443 default ssl;  
server\_name [dev.mysite.com](http://dev.mysite.com);

```
access_log /var/log/nginx/dev_mysite_access.log;
error_log /var/log/nginx/dev_mysite_error.log;

ssl_certificate /export/nginx/certs/mysite.com.crt;
ssl_certificate_key /export/nginx/certs/mysite.com.key;

location / {
    # give site more time to respond
    proxy_read_timeout 120;

    # needed to forward user's IP address
    proxy_set_header X-Real-IP $remote_addr;

    # needed for HTTPS
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header Host $http_host;
    proxy_redirect off;
    proxy_max_temp_file_size 0;

    proxy_pass http://localhost:8081;
}

```

}

Posted at Nginx Forum:

> **[Trouble getting SSL and proxying to work correctly](https://forum.nginx.org/read.php?2,121531,121531#msg-121531)**
>
> I have Googled and looked at various sample SSL configurations and it seems like I've got things set up right, but there are two problems I can't seem to fix: 1. When I load https://dev.mysite.com, the lock that should appear in the upper right...
