probleme with http to https redirect

lincore nginx-forum at
Tue Jun 30 17:16:15 MSD 2009

Hello Everyone,

I've try to use nginx as ssl front-end for tomcat with ssl, and use port 8081 for front-end and back-end, but redirect from http to https does not work in this case.

Extract from nginx.conf:
server {
    listen       some_ip:8081;
    server_name some_name_tld;
    ssl          on;
    ssl_certificate /usr/local/nginx/ssl/server.crt;
    ssl_certificate_key /usr/local/nginx/ssl/server.key;
    ssl_protocols SSLv3 TLSv1;
    ssl_session_cache builtin:1024;
    ssl_session_timeout 30m;

    gzip on;
    gzip_types text/javascript text/css application/xml text/xml;
    gzip_proxied any;

    rewrite ^ https://$server_name:$server_port$request_uri redirect;

    location /{

        proxy_redirect     off;

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

But following redirect works, if nginx  listening on port 80.
Andrey Filatov.

Posted at Nginx Forum:,3556,3556#msg-3556

More information about the nginx mailing list