O
O
Ockonal2016-06-30 23:25:12
Nginx
Ockonal, 2016-06-30 23:25:12

How to cache on nginx with https?

Hello, there is nginx + php-fpm, the main server directive hangs at 443:

server {
    listen 443 ssl;
    # ssl settings here
    ...
}


Port 80 is redirected to https:

server {
    listen 80;
    server_name             book-audio.com *.book-audio.com;
    return 301 https://$host$request_uri;
}


The question is how to enable nginx caching in such a bundle? Tried adding another directive:

server {
        listen 80;

        location / {
                proxy_pass https://127.0.0.1:81/;
                proxy_cache all;
                proxy_cache_valid any 1h;
                proxy_cache_valid 404 502 503 1m;
                fastcgi_cache fcgi;
                fastcgi_cache_valid 200 60m;
        }
}

And the main section instead of 443 -> 81. But that doesn't work, right?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey, 2016-06-30
@Ockonal

You overdid something.
Redirect http -> https is fine.
All other settings in the section with listen 443 ssl.
In the same place all your location are described.
127.0.0.1:81 is the address of your php-fpm (usually 127.0.0.1:9000)
You continue to access the site https://site.ru without specifying the port.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question