G
G
gh0sty2019-12-06 17:29:06
Nginx
gh0sty, 2019-12-06 17:29:06

How to correctly combine caching and www, https redirection for nginx?

In general, I wrote a redirect from www and http to https without www. Now I want to combine caching like in this article and my config. Can I use any other verified ports that are valid for SSL so as not to lose browser and search engine support?

Config:

server {
        listen 80;
        server_name .... www.site.com site.com;
        return 301 https://site.com$request_uri;
}

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

        ssl_certificate /home/sv/certs/certificate.crt;
        ssl_certificate_key /home/sv/certs/private.key;
        ssl_session_cache shared:SSL:10m;
        ssl_session_timeout 10m;
        ssl_buffer_size 4k;

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

server {
        gzip on;
        gzip_buffers 16 8k;
        gzip_comp_level 2;
        gzip_min_length 1024;
        gzip_types text/css text/plain text/json text/x-js text/javascript text/xml application/json application/x-java$
        gzip_disable "msie6";
        gzip_vary on;
        gzip_http_version 1.0;

        listen 443 ssl;
        server_name .... site.com;

        ssl_certificate /home/sv/certs/certificate.crt;
        ssl_certificate_key /home/sv/certs/private.key;
        ssl_session_cache shared:SSL:10m;
        ssl_session_timeout 10m;
        ssl_buffer_size 4k;

        location /files/ {
                alias /home/sv/site/static/;
        }

        location /pics/ {
                alias /home/sv/site/media/;
        }

        location / {
                include         uwsgi_params;
                uwsgi_pass      unix:/run/uwsgi/site.sock;
        }
}


If not difficult, throw a couple of lines))) I would be sincerely grateful.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
G
gh0sty, 2019-12-06
@gh0sty

After an hour of searching, I found: This should be thrown into the media and static location. Sorry for my stupidity, I don't know about nginx)) So and so - this is a good config for beginners under uwsgi and django.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question