Proxy problem

Hi,

We had nginx/0.6.33 and we migrated to nginx/0.7.65.
We use nginx as frontend for our webmail, that it is in another machine
(nginx+apache).
But in the new scenario, squirrelmail loss session (I guess) and force
me
to relogin again.
Compile options and config files are the same (except for
proxy_redirect)

This is:
location / {
proxy_pass http://mailmachine:80;
proxy_redirect default; // for nginx 0.7.65
proxy_redirect on; // for nginx 0.6.33

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

$proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto https;
client_max_body_size 10m;
client_body_buffer_size 128k;
proxy_connect_timeout 90;
proxy_send_timeout 90;
proxy_read_timeout 90;
proxy_buffering on;
proxy_buffers 8 8k;
proxy_buffer_size 8k;
proxy_busy_buffers_size 16k;
proxy_temp_file_write_size 1024m;
}

What changes are in version 0.7 that I should consider?

Thank you in advance,
Lucas

Hi,

Sorry, it was because rewrite was doing its jobs unexpected.
We solved with this code:

    location / {
            rewrite ^(.*) https://webmail.landm.net$1 permanent;
    }

Regards,
Lucas

On Mon, Jun 07, 2010 at 04:33:18PM +0200, [email protected] wrote:

Hi,

Sorry, it was because rewrite was doing its jobs unexpected.
We solved with this code:

    location / {
            rewrite ^(.*) https://webmail.landm.net$1 permanent;
    }

I do not see how this rewrite may resolve the issue.
BTW,

     proxy_redirect     on; // for nginx 0.6.33

is wrong for 0.6.x as well as 0.7.x.

Compile options and config files are the same (except for proxy_redirect)
$proxy_add_x_forwarded_for;
proxy_temp_file_write_size 1024m;
nginx mailing list
[email protected]
nginx Info Page


nginx mailing list
[email protected]
nginx Info Page


Igor S.
http://sysoev.ru/en/

Hi Igor,

We solved with this code:

    location / {
            rewrite ^(.*) https://server$1 permanent;
    }

I do not see how this rewrite may resolve the issue.

The problem was an internal redirection from squirrelmail. Doing some
operation, it redirects to http://server/ [no SSL ] and the previous
code:

     location / {
             rewrite ^(.*) https://server/ last;
     }

lost the session.

Regards,
Lucas

On Mon, Jun 07, 2010 at 04:55:04PM +0200, [email protected] wrote:

The problem was an internal redirection from squirrelmail. Doing some
operation, it redirects to http://server/ [no SSL ] and the previous
code:

     location / {
             rewrite ^(.*) https://server/ last;
     }

lost the session.

You may fix this using proper proxy_redirect’s, e.g.:

 location / {
     proxy_pass      http://mailmachine:80;
     proxy_redirect  http://server/   https://server/;

Regards,

to relogin again.
proxy_set_header X-Real-IP $remote_addr;
proxy_buffer_size 8k;

nginx Info Page


nginx mailing list
[email protected]
nginx Info Page


Igor S.
http://sysoev.ru/en/

On 07.06.2010 17:55, [email protected] wrote:

The problem was an internal redirection from squirrelmail. Doing some
operation, it redirects to http://server/ [no SSL ]

you need

SetEnv HTTPS on

in apache config for squirrelmail virtual host.

or more advanced code in nginx and apache config:

========================================================================

nginx config:

proxy_set_header X-Nginx-Scheme $scheme;

nginx variable $scheme will be ‘http’ or ‘https’.

apache config:

SetEnvIf X-Nginx-Scheme “^https$” HTTPS=on

Apache environment variable HTTPS will be ‘on’ or not defined.

PHP code:

$scheme = getenv(‘HTTPS’) && strtolower(getenv(‘HTTPS’)) != ‘off’
? ‘https’
: ‘http’;

PHP variable $scheme will be ‘http’ or ‘https’.

========================================================================

check for HTTPS environment variable already implemented inside
squirrelmail: function is_ssl_secured_connection() in
functions\global.php.

P.S. also you need something like

proxy_redirect https://mail.example.com:80/ /;

in nginx config, because squirrelmail can make redirects
to 80 port instead of default for HTTPS, 443 port.


Best regards,
Gena