Welcome! Log In Create A New Profile

Advanced

Re: rewrite all locations to https except one

Maxim Dounin
October 18, 2012 05:24AM
Hello!

On Thu, Oct 18, 2012 at 05:17:27AM -0400, karolis wrote:

> Hi Everyone,
>
> i have this problem with rewrite. As subject says i want to rewrite all
> locations to https except one, that should remain http. But that one with
> http isn't redirecting properly. I'm using nginx 1.2.2 version. Here's my
> conf:
>
> server {
> client_max_body_size 500M;
> listen 80;
> server_name alis.am.lt;
> #rewrite ^(.*) https://$host$1 permanent;
> #rewrite ^ https://$server_name$request_uri? permanent;
>
> location / {
> rewrite ^(.*) https://$host$1 permanent;
> proxy_pass http://www_serveriai_80;
> proxy_set_header Host $http_host;
> }

Just a side note: it doesn't make sense to write proxy_pass here.
Using

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

would be enough. Or, better,

location / {
return 301 https://$host$request_uri;
}

> location /SomeService {
> rewrite ^(.*) http://$host$1 permanent;

This will create infinite loop, as you try to redirect back to the
same address. Just remove this rewrite.

> proxy_method POST;
> proxy_pass http://10.255.6.120:8080/SomeService;
> proxy_set_header Host $http_host;
> #proxy_redirect default;
> #proxy_set_header Host $host;
> #proxy_set_header X-Real-IP $remote_addr;
> #proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
> }
>
>
> I really appreciate any help. Thanks!

--
Maxim Dounin
http://nginx.com/support.html

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

rewrite all locations to https except one

karolis October 18, 2012 05:17AM

Re: rewrite all locations to https except one

Maxim Dounin October 18, 2012 05:24AM

Re: rewrite all locations to https except one

karolis October 18, 2012 07:32AM

Re: rewrite all locations to https except one

Maxim Dounin October 18, 2012 08:04AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 250
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready