0

I would like to serve some of my website static assets like .txt, .csv, images and other document types as non https. But my current configuration always redirects to https.

server {
        listen 80;
        listen [::]:80;

        root /var/www/public;
        index index.php index.html index.htm;

        server_name example.com www.example.com;

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

        location /static/ {
                root /var/www/public/static;
        }
}

server {
        listen 443 ssl http2;
        listen [::]:443 ssl http2;

        include snippets/ssl-example.com.conf;
        include snippets/ssl-params.conf;

        root /var/www/public;
        index index.php index.html index.htm;

        server_name example.com www.example.com;

        location / {
                try_files $uri $uri/ /index.php?$query_string;
        }

        location ~ \.php$ {
                include snippets/fastcgi-php.conf;
                fastcgi_pass unix:/var/run/php/php8.0-fpm.sock;
        }
}

I have been reading similar questions here in SO:

But nothing works for me and worst returns too many redirect.

Deon
  • 153
  • 2
  • 14

0 Answers0