Jump to content

Recommended Posts

Добрый день!

Переношу сайт с апача на nginx + php-fpm


Может кто нибудь поделиться хорошим конфигом?

Заранее спасибо!

Share this post


Link to post
Share on other sites
server {
	server_name site.ru www.site.ru;
	listen 00.00.00.00:80;
	return 301 https://site.ru$request_uri;
}

server {
	server_name www.site.ru;
	listen 00.00.00.00:443 ssl http2;
	ssl on;
	ssl_certificate "/var/www/httpd-cert/www-root/site.ru_le1.crtca";
	ssl_certificate_key "/var/www/httpd-cert/www-root/site.ru_le1.key";
	ssl_ciphers EECDH:+AES256:-3DES:RSA+AES:!NULL:!RC4;
	ssl_prefer_server_ciphers on;
	ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
	add_header Strict-Transport-Security "max-age=31536000;";
	ssl_dhparam /etc/ssl/certs/dhparam4096.pem;
	return 301 https://site.ru$request_uri;
}

server {
	server_name site.ru;
	listen 00.00.00.00:443 ssl http2;
	ssl on;
	ssl_certificate "/var/www/httpd-cert/www-root/site.ru_le1.crtca";
	ssl_certificate_key "/var/www/httpd-cert/www-root/site.ru_le1.key";
	ssl_ciphers EECDH:+AES256:-3DES:RSA+AES:!NULL:!RC4;
	ssl_prefer_server_ciphers on;
	ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
	add_header Strict-Transport-Security "max-age=31536000;";
	ssl_dhparam /etc/ssl/certs/dhparam4096.pem;
	
	charset UTF-8;
	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;

	set $root_path /var/www/www-root/data/www/site.ru;
	root $root_path;
	
	location /admin {
        index index.php;
    }
	
	location / {
        try_files $uri $uri/ @opencart;
    }
    
    location @opencart {
        rewrite ^/(.+)$ /index.php?_route_=$1 last;
    }
    
     location /index.html {
        rewrite ^(.*)$ https://site.ru/ permanent;
    } 
    
	location ~* ^.+\.(jpg|jpeg|gif|png|svg|svgz|eot|otf|woff|ttf|js|css|mp3|ogg|mpe?g|avi|zip|gz|bz2?|rar|swf)$ {
		expires max;
		etag on;
		log_not_found off;
	}
	
    location ~* (\.(tpl|ini))$ {
        deny all;
    }
    
    location ~ (?i)((\.tpl|\.ini|\.log|(?<!robots)\.txt)) {
        deny all;
    }
    
    location ~ [^/]\.php(/|$) {
		fastcgi_index index.php;
		fastcgi_pass unix:/var/www/php-fpm/www-root.sock;
		fastcgi_split_path_info ^((?U).+\.ph(?:p\d*|tml))(/?.+)$;
		try_files $uri =404;
		include fastcgi_params;
	}
}

 

ip подставляете свой

 

 

Share this post


Link to post
Share on other sites
1 hour ago, zlob said:

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

 

ip подставляете свой

 

 

спасибо!

а есть настройки для fastcgi?

Edited by zfgad

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
You are posting as a guest. If you have an account, please sign in.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • 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.