Advertisement
Guest User

Untitled

a guest
Feb 14th, 2020
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Nginx 1.62 KB | None | 0 0
  1. server {
  2.     server_name site.ru;
  3.     charset off;
  4.  
  5.     access_log /var/www/site.ru/logs/access.log;
  6.     error_log /var/www/site.ru/logs/error.log;
  7.  
  8.     root /var/www/site.ru/public;
  9.     index index.php index.html;
  10.  
  11.  
  12.     # serve static files directly
  13.     location ~* \.(jpg|jpeg|gif|css|png|js|ico|html|txt)$ {
  14.         access_log off;
  15.         expires max;
  16.         log_not_found off;
  17.     }
  18.    
  19.  
  20.     # removes trailing slashes (prevents SEO duplicate content issues)
  21.     if (!-d $request_filename)
  22.     {
  23.         rewrite ^/(.+)/$ /$1 permanent;
  24.     }
  25.  
  26.     # enforce NO www
  27.     if ($host ~* ^www\.(.*))
  28.     {
  29.         set $host_without_www $1;
  30.         rewrite ^/(.*)$ $scheme://$host_without_www/$1 permanent;
  31.     }
  32.  
  33.  
  34.     location / {
  35.         set $root "/var/www/site.ru/public";
  36.         try_files $uri $uri/ /index.php?$query_string;
  37.  
  38.         # unless the request is for a valid file (image, js, css, etc.), send to bootstrap
  39.         if (!-e $request_filename)
  40.         {
  41.             rewrite ^/(.*)$ /index.php?/$1 last;
  42.             break;
  43.         }
  44.    
  45.     }
  46.    
  47.     location /i {
  48.         set $root "/var/www/test";
  49.         root $root;
  50.         try_files $uri $uri/ /index.php?$query_string;
  51.        
  52.         # unless the request is for a valid file (image, js, css, etc.), send to bootstrap
  53.         if (!-e $request_filename)
  54.         {
  55.             rewrite ^/(.*)$ /index.php?/$1 last;
  56.             break;
  57.         }
  58.  
  59.     }
  60.  
  61.     location ~* \.php$ {
  62.                 root $root;
  63.         try_files $uri = 404;
  64.         fastcgi_split_path_info ^(.+\.php)(/.+)$;
  65.         fastcgi_pass unix:/var/run/php/php7.2-fpm.sock; # may also be: 127.0.0.1:9000;
  66.         fastcgi_index index.php;
  67.         fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  68.         include fastcgi_params;
  69.     }
  70.  
  71.     location ~ /\.ht {
  72.         deny all;
  73.     }
  74.  
  75.    
  76. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement