Trouble getting SSL and proxying to work correctly

janine nginx-forum at
Fri Aug 20 03:37:01 MSD 2010

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, 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
instead of

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, but neither had any effect.  Setting Host to 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

server {
    listen       443 default ssl;

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

    ssl_certificate /export/nginx/certs/;
    ssl_certificate_key /export/nginx/certs/;

    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:,121531,121531#msg-121531

More information about the nginx mailing list