Jump to content
Sign in to follow this  
mmaxx777

Правильный конфиг NGINX

Recommended Posts

Приветствую!

Подскажите, пожалуйста, как будет правильнее сформировать конфиг, чтобы работала админка и seo url? Используется связка nginx + php-fpm и кеширование.

Заранее благодарен.

server {
	server_name site.ru www.site.ru;
	charset off;
	index index.php index.html;
	disable_symlinks if_not_owner from=$root_path;
	include /etc/nginx/vhosts-includes/*.conf;
	include /etc/nginx/vhosts-resources/site.ru/*.conf;
	access_log /var/www/httpd-logs/site.ru.access.log;
	error_log /var/www/httpd-logs/site.ru.error.log notice;
	ssi on;
	set $root_path /var/www/admin/data/www/site.ru;
	root $root_path;
	location / {
	    try_files $uri @opencart;
		location ~ [^/]\.ph(p\d*|tml)$ {
			try_files /does_not_exists @php;
		}
		location ~* ^.+\.(jpg|jpeg|gif|png|svg|js|css|mp3|ogg|mpe?g|avi|zip|gz|bz2?|rar|swf)$ {
			expires 15m;
		}
	}
	location @opencart { rewrite ^/(.+)$ /index.php?_route_=$1 last; }
	location @php {
		fastcgi_index index.php;
		fastcgi_param PHP_admin_VALUE "sendmail_path = /usr/sbin/sendmail -t -i -f [email protected]";
		fastcgi_pass unix:/var/www/php-fpm/admin.sock;
		fastcgi_split_path_info ^((?U).+\.ph(?:p\d*|tml))(/?.+)$;
		try_files $uri =404;
		include fastcgi_params;
	}
	gzip on;
	gzip_comp_level 5;
	gzip_disable "msie6";
	gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript application/javascript;
	listen 82.156.47.510:80;
}
server {
	server_name site.ru www.site.ru;
	ssl_certificate "/var/www/httpd-cert/admin/site.ru.crtca";
	ssl_certificate_key "/var/www/httpd-cert/admin/site.ru.key";
	ssl_ciphers EECDH:+AES256:-3DES:RSA+AES:!NULL:!RC4;
	ssl_prefer_server_ciphers on;
	ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
	ssl_dhparam /etc/ssl/certs/dhparam4096.pem;
	charset off;
	index index.php index.html;
	disable_symlinks if_not_owner from=$root_path;
	include /etc/nginx/vhosts-includes/*.conf;
	include /etc/nginx/vhosts-resources/site.ru/*.conf;
	access_log /var/www/httpd-logs/site.ru.access.log;
	error_log /var/www/httpd-logs/site.ru.error.log notice;
	ssi on;
	set $root_path /var/www/admin/data/www/site.ru;
	root $root_path;
	listen 82.156.47.510:443 ssl;
	gzip on;
	gzip_comp_level 5;
	gzip_disable "msie6";
	gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript application/javascript;
	location / {
	    try_files $uri @opencart;
	
		location ~ [^/]\.ph(p\d*|tml)$ {
			try_files /does_not_exists @php;
		}
		location ~* ^.+\.(jpg|jpeg|gif|png|svg|js|css|mp3|ogg|mpe?g|avi|zip|gz|bz2?|rar|swf)$ {
			expires 15m;
		}
	}
	location @opencart { rewrite ^/(.+)$ /index.php?_route_=$1 last; }
	location @php {
		fastcgi_index index.php;
		fastcgi_param PHP_ADMIN_VALUE "sendmail_path = /usr/sbin/sendmail -t -i -f [email protected]";
		fastcgi_pass unix:/var/www/php-fpm/admin.sock;
		fastcgi_split_path_info ^((?U).+\.ph(?:p\d*|tml))(/?.+)$;
		try_files $uri =404;
		include fastcgi_params;
	}
}

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×

Important Information

On our site, cookies are used and personal data is processed to improve the user interface. To find out what and what personal data we are processing, please go to the link. If you click "I agree," it means that you understand and accept all the conditions specified in this Privacy Notice.