A
A
Artem2015-04-22 09:23:34
Nginx
Artem, 2015-04-22 09:23:34

Is it possible to disable redirect from http to https for individual pages?

Good afternoon, there is: Frontend
server: Nginx
Backend server: Apache
Now visiting the address: example.com there is a 301 redirect to https://www.example.com
And so for all pages, there is a redirect to a similar page but to https ://www.
Question: Is it possible to set exceptions in the Nginx config for individual pages that should be accessible only via the http protocol? Right now I have about 160 pages on the site that should only be accessible via the http protocol.
Is it possible?
What changes to the Nginx config need to be made?
PS: An example of the current Nginx config for a single site:

server {
    listen 80;
    rewrite ^ https://www.example.com$request_uri permanent;
}

server {
    server_name example.com;

    listen 443 ssl spdy;
    ssl_certificate         /etc/nginx/ssl/example.com.pem;
    ssl_certificate_key     /etc/nginx/ssl/example.com.pem;

    rewrite ^ https://www.example.com$request_uri permanent;

}

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

    listen 443 ssl spdy;
    ssl_certificate         /etc/nginx/ssl/example.com.pem;
    ssl_certificate_key     /etc/nginx/ssl/example.com.pem;

    access_log off;
    #access_log /home/www/example.com/logs/example.com-acc main;
    error_log /home/www/example.com/logs/example.com-err;

    client_max_body_size 256m;

    location / {
        if ($scheme = http) {
            return 301 https://www.example.com$request_uri;
        }
        proxy_pass http://127.0.0.1:8080;
        proxy_redirect off;
        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_read_timeout 300;
        proxy_buffer_size 16k;
        proxy_buffers 32 16k;
    }

    location ~* \.(jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|txt|tar|mid|midi|wav|bmp|rtf|js|swf|flv|avi|djvu|mp3|mp4|ogv|3gp|otf)$ {
        root /home/www/example.com/htdocs;
    }

    include vhost.inc.conf;
}

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question