H
H
HocReal2016-09-01 16:19:25
Nginx
HocReal, 2016-09-01 16:19:25

How to configure nginx redirect with exception by url?

The situation is as follows, there is Nginx as a proxy to Apache,
all requests on port 80 are redirected to port 443, it is done like this:

server {
    listen 80;
    server_name site.com www.site.com *.site.com;

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

server {
        listen 443;

How to make it so that requests for a specific URL are not redirected to port 443,
these will be regular URLs /system/handle/([0-9a-f]+)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
L
Lynn "Coffee Man", 2016-09-01
@HocReal

Add the appropriate `location`

server {
    listen 80;
    server_name site.com www.site.com *.site.com;

    location / {
        return 301 https://site.com$request_uri;
    }

    location /system/handle/ {
        # делать что надо
    }
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question