misitio.conf 1.49 KB
Newer Older
abkrim's avatar
abkrim committed
1 2 3
# For learn pourpueos about post
# https://castris.com/cpanel-no-gracias-lemp-sin-panel-de-control/
# Is for use wuth 80 before instal certificate with cerbot
4
server {
abkrim's avatar
abkrim committed
5
    listen      80;
6
    server_name domain.tld;
abkrim's avatar
abkrim committed
7
    root        /home/USER/web/domain.tld;
8 9
    index       index.php index.html index.htm;
    access_log  /var/log/nginx/domains/domain.tld.log combined;
abkrim's avatar
abkrim committed
10
    # access_log  /var/log/nginx/domains/domain.tld.bytes bytes; # Some versions nginx not work
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
    error_log   /var/log/nginx/domains/domain.tld.error.log error;

    expires $expires;
    
    include /etc/nginx/modsec/active.conf;

    location = /favicon.ico {
        log_not_found off;
        access_log off;
    }

    location = /robots.txt {
        allow all;
        log_not_found off;
        access_log off;
    }

    location / {
        try_files $uri $uri/ /index.php;
        
        if (!-e $request_filename)
        {
            rewrite ^(.+)$ /index.php?q=$1 last;
        }

        location ~* ^.+\.(jpeg|jpg|png|gif|bmp|ico|svg|css|js)$ {
            expires     max;
        }

        location ~* \.php$ {
	    fastcgi_split_path_info ^(.+?\.php)(/.*)$;
	    if (!-f $document_root$fastcgi_script_name) {return 404;}
43
	    fastcgi_pass  unix:/run/php/MYSITE-fpm.sock;
44 45 46 47 48 49 50 51 52 53 54
	    fastcgi_index index.php;
	    include         /etc/nginx/fastcgi_params;
	    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        }
    }

    location ~* "/\.(htaccess|htpasswd)$" {
        deny    all;
        return  404;
    }
}