Welcome! Log In Create A New Profile

Advanced

Re: rewrite all locations to https except one

Maxim Dounin
October 18, 2012 08:04AM
Hello!

On Thu, Oct 18, 2012 at 07:32:03AM -0400, karolis wrote:

> Thanks Maxim for your help. But then where to write this proxy_pass:
>
> proxy_pass http://www_serveriai_80;
>
> And still, going further in my site, https drops off and i'm being left only
> with http. How to permanently stay on https, but in this location:
>
> location /SomeService {
> proxy_method POST;
> proxy_pass http://10.255.6.120:8080/SomeService;
> proxy_set_header Host $http_host;
>
> to stay always on http.
> Thanks

The server{} block you provided is http-only, not https. On the
other hand, what you ask about needs correct configuration of two
server blocks, one for http, and another one for https.

Here is an example:

server {
listen 80;
server_name www.example.com;

location / {
# we are in http server, but want https for normal
# requests - redirect to https

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

location /http_only_service {
... do real work here ...
}
}

server {
listen 443 ssl;
server_name www.example.com;

ssl_certificate ...
ssl_certificate_key ...

location / {
... do real work here ...
}

location /http_only_service {
# this is http only service, but we are in https
# server - redirect to http

return 301 http://$host$request_uri;
}
}

Hope this helps.

--
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: 326
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