Пример конфигурационного файла для nginx — различия между версиями
Материал из Umicms
Mad grant (обсуждение | вклад) (Новая страница: «category:Вопросы установки настройки и переноса == Пример №1 == <source lang=""> </source> == Пример №2 == …») |
Mad grant (обсуждение | вклад) |
||
Строка 3: | Строка 3: | ||
== Пример №1 == | == Пример №1 == | ||
− | <source lang=""> | + | <source lang="apache"> |
+ | server { | ||
+ | listen 80; | ||
+ | server_name ~^(www\.)?test(?<id>\d+)(?<alias>-alias)?.srv23.megaserver.umisoft.ru; | ||
+ | root /home/testfarm/test$id/htdocs/; | ||
+ | |||
+ | client_max_body_size 10m; | ||
+ | |||
+ | rewrite_log on; | ||
+ | access_log /home/testfarm/nginx_access.log; | ||
+ | error_log /home/testfarm/nginx_error.log debug; | ||
+ | |||
+ | location ~* \/\.ht { | ||
+ | deny all; | ||
+ | } | ||
+ | |||
+ | location ~* ^\/(classes|errors\/logs|sys\-temp|cache|xmldb|static|packages) { | ||
+ | deny all; | ||
+ | } | ||
+ | |||
+ | location ~* (\/for_del_connector\.php|\.ini|\.conf)$ { | ||
+ | deny all; | ||
+ | } | ||
+ | |||
+ | location ~* ^(\/files\/|\/images\/) { | ||
+ | try_files $uri =404; | ||
+ | } | ||
+ | |||
+ | location ~* ^\/images\/autothumbs\/ { | ||
+ | try_files $uri @autothumbs =404; | ||
+ | } | ||
+ | |||
+ | location @autothumbs { | ||
+ | rewrite ^\/images\/autothumbs\/(.*)$ /autothumbs.php?img=$1$query_string last; | ||
+ | } | ||
+ | |||
+ | location @clean_url { | ||
+ | rewrite ^/(.*)$ /index.php?path=$1 last; | ||
+ | } | ||
+ | |||
+ | location @dynamic { | ||
+ | try_files $uri @clean_url; | ||
+ | } | ||
+ | |||
+ | location / { | ||
+ | rewrite ^\/robots\.txt /sbots.php?path=$1 last; | ||
+ | rewrite ^\/sitemap\.xml /sitemap.php last; | ||
+ | rewrite ^\/\~\/([0-9]+)$ /tinyurl.php?id=$1 last; | ||
+ | rewrite ^\/(udata|upage|uobject|ufs|usel|ulang|utype|umess|uhttp):?(\/\/)?(.*)? /releaseStreams.php?scheme=$1&path=$3 last; | ||
+ | rewrite ^\/(.*)\.xml$ /index.php?xmlMode=force&path=$1 last; | ||
+ | rewrite ^(.*)\.json$ /index.php?jsonMode=force&path=$1 last; | ||
+ | if ($cookie_umicms_session) { | ||
+ | error_page 412 = @dynamic; | ||
+ | return 412; | ||
+ | } | ||
+ | if ($request_method = 'POST') { | ||
+ | error_page 412 = @dynamic; | ||
+ | return 412; | ||
+ | } | ||
+ | try_files /sys-temp/static-cache/test$id$alias.srv23.megaserver.umisoft.ru/$uri/index.html @dynamic; | ||
+ | } | ||
+ | |||
+ | location ~* \.js$ { | ||
+ | rewrite ^\/(udata|upage|uobject|ufs|usel|ulang|utype|umess|uhttp):?(\/\/)?(.*)? /releaseStreams.php?scheme=$1&path=$3 last; | ||
+ | try_files $uri =404; | ||
+ | } | ||
+ | |||
+ | location ~* \.(ico|jpg|jpeg|png|gif|swf|css)$ { | ||
+ | try_files $uri =404; | ||
+ | access_log off; | ||
+ | expires 1m; | ||
+ | } | ||
+ | |||
+ | location ~* \.php$ { | ||
+ | fastcgi_pass 127.0.0.1:9000; | ||
+ | fastcgi_read_timeout 3600; | ||
+ | include fastcgi_params; | ||
+ | } | ||
+ | } | ||
+ | |||
</source> | </source> | ||
== Пример №2 == | == Пример №2 == | ||
− | <source lang=""> | + | <source lang="apache"> |
+ | server { | ||
+ | listen 80; | ||
+ | server_name www.website.ru website.ru; | ||
+ | root /home/website/website.ru/www; | ||
+ | index index.php; | ||
+ | charset utf-8; | ||
+ | |||
+ | access_log /home/website/website.ru/logs/access.log; | ||
+ | error_log /home/website/website.ru/logs/error.log warn; | ||
+ | |||
+ | if ( $request_uri ~ "^/images") { break; } | ||
+ | if ( $request_uri ~ "^/tinymce") { break; } | ||
+ | if ( $request_uri ~ "^/install.php") { break; } | ||
+ | if ( $request_uri ~ "^/install_update.php") { break; } | ||
+ | if ( $request_uri ~ "^/captcha.php") { break; } | ||
+ | if ( $request_uri ~ "^/styles") { break; } | ||
+ | if ( $request_uri ~ "^/css") { break; } | ||
+ | if ( $request_uri ~ "\.css$") { break; } | ||
+ | if ( $request_uri ~ "^js") { break; } | ||
+ | if ( $request_uri ~ "^/js") { break; } | ||
+ | |||
+ | # если вы наблюдаете проблемы с compressed.js или compiled.js, закомментируйте следующую строку | ||
+ | #if ( $request_uri ~ "\.js$") { break; } | ||
+ | |||
+ | #if ( $request_uri ~ "^/webstat") { break; } | ||
+ | |||
+ | |||
+ | if (-e $request_filename) { | ||
+ | rewrite ^/(sys\-temp|cache|xmldb|static|packages)\/.*$ /500/ break; | ||
+ | } | ||
+ | if (!-e $request_filename) { | ||
+ | rewrite ^/robots\.txt /sbots.php?path=$1&$query_string last; | ||
+ | rewrite ^/sitemap\.xml /sitemap.php last; | ||
+ | rewrite ^(.*)\.xml$ /index.php?xmlMode=force&path=$1&$query_string last ; | ||
+ | rewrite ^/(udata|upage|uobject|ufs|usel|ulang|utype|umess|uhttp):?(\/\/)?(.*)$ /releaseStreams.php?scheme=$1&path=$3?$query_string last; | ||
+ | rewrite ^(.*)\.json$ /index.php?jsonMode=force&path=$1&%query_string last; | ||
+ | rewrite ^/.* /index.php?path=$fastcgi_script_name&$query_string last; | ||
+ | } | ||
+ | |||
+ | location / { | ||
+ | rewrite ^/~/([0-9]+)$ /tinyurl.php?id=$1 break; | ||
+ | root /home/website/website.ru/www; | ||
+ | index index.php; | ||
+ | } | ||
+ | |||
+ | location ~* (config\.ini|install\.ini|install\.log|umi\.nginx\.conf|dbview\.php|umibackup) { | ||
+ | rewrite ^(.*)$ / permanent; | ||
+ | } | ||
+ | |||
+ | location = /config.ini { | ||
+ | deny all; | ||
+ | } | ||
+ | #deny /classes access | ||
+ | location ^~ /classes { | ||
+ | deny all; | ||
+ | } | ||
+ | location ^~ /errors/logs/ { | ||
+ | deny all; | ||
+ | } | ||
+ | location ^~ /libs/ { | ||
+ | deny all; | ||
+ | } | ||
+ | location ^~ /sys-temp/ { | ||
+ | deny all; | ||
+ | } | ||
+ | location ^~ /tpls/ { | ||
+ | deny all; | ||
+ | } | ||
+ | location ^~ /umaps/ { | ||
+ | deny all; | ||
+ | } | ||
+ | location ^~ /usels/ { | ||
+ | deny all; | ||
+ | } | ||
+ | location ^~ /xsltTpls/ { | ||
+ | deny all; | ||
+ | } | ||
+ | location ^~ /styles/common/other/elfinder/php/ { | ||
+ | location ~.*\.(php)?$ | ||
+ | { | ||
+ | deny all; | ||
+ | } | ||
+ | } | ||
+ | #disable php in /files/ | ||
+ | location ~* /files/ { } | ||
+ | |||
+ | location ~* ^.+\.(php)$ { | ||
+ | root /home/website/website.ru/www; | ||
+ | |||
+ | fastcgi_pass unix:/tmp/php-website.sock; | ||
+ | fastcgi_index index.php; | ||
+ | fastcgi_param SCRIPT_FILENAME /website.ru/www$fastcgi_script_name; | ||
+ | include fastcgi_params; | ||
+ | |||
+ | fastcgi_connect_timeout 60; | ||
+ | fastcgi_send_timeout 180; | ||
+ | fastcgi_read_timeout 180; | ||
+ | fastcgi_buffer_size 32k; | ||
+ | fastcgi_buffers 4 32k; | ||
+ | fastcgi_busy_buffers_size 32k; | ||
+ | fastcgi_temp_file_write_size 32k; | ||
+ | fastcgi_temp_path /tmp; | ||
+ | } | ||
+ | |||
+ | |||
+ | error_page 500 502 503 504 /50x.html; | ||
+ | location = /50x.html { | ||
+ | root /usr/local/www/nginx-dist; | ||
+ | } | ||
+ | |||
+ | } | ||
</source> | </source> |
Версия 14:43, 23 октября 2013
Пример №1
server {
listen 80;
server_name ~^(www\.)?test(?<id>\d+)(?<alias>-alias)?.srv23.megaserver.umisoft.ru;
root /home/testfarm/test$id/htdocs/;
client_max_body_size 10m;
rewrite_log on;
access_log /home/testfarm/nginx_access.log;
error_log /home/testfarm/nginx_error.log debug;
location ~* \/\.ht {
deny all;
}
location ~* ^\/(classes|errors\/logs|sys\-temp|cache|xmldb|static|packages) {
deny all;
}
location ~* (\/for_del_connector\.php|\.ini|\.conf)$ {
deny all;
}
location ~* ^(\/files\/|\/images\/) {
try_files $uri =404;
}
location ~* ^\/images\/autothumbs\/ {
try_files $uri @autothumbs =404;
}
location @autothumbs {
rewrite ^\/images\/autothumbs\/(.*)$ /autothumbs.php?img=$1$query_string last;
}
location @clean_url {
rewrite ^/(.*)$ /index.php?path=$1 last;
}
location @dynamic {
try_files $uri @clean_url;
}
location / {
rewrite ^\/robots\.txt /sbots.php?path=$1 last;
rewrite ^\/sitemap\.xml /sitemap.php last;
rewrite ^\/\~\/([0-9]+)$ /tinyurl.php?id=$1 last;
rewrite ^\/(udata|upage|uobject|ufs|usel|ulang|utype|umess|uhttp):?(\/\/)?(.*)? /releaseStreams.php?scheme=$1&path=$3 last;
rewrite ^\/(.*)\.xml$ /index.php?xmlMode=force&path=$1 last;
rewrite ^(.*)\.json$ /index.php?jsonMode=force&path=$1 last;
if ($cookie_umicms_session) {
error_page 412 = @dynamic;
return 412;
}
if ($request_method = 'POST') {
error_page 412 = @dynamic;
return 412;
}
try_files /sys-temp/static-cache/test$id$alias.srv23.megaserver.umisoft.ru/$uri/index.html @dynamic;
}
location ~* \.js$ {
rewrite ^\/(udata|upage|uobject|ufs|usel|ulang|utype|umess|uhttp):?(\/\/)?(.*)? /releaseStreams.php?scheme=$1&path=$3 last;
try_files $uri =404;
}
location ~* \.(ico|jpg|jpeg|png|gif|swf|css)$ {
try_files $uri =404;
access_log off;
expires 1m;
}
location ~* \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_read_timeout 3600;
include fastcgi_params;
}
}
Пример №2
server {
listen 80;
server_name www.website.ru website.ru;
root /home/website/website.ru/www;
index index.php;
charset utf-8;
access_log /home/website/website.ru/logs/access.log;
error_log /home/website/website.ru/logs/error.log warn;
if ( $request_uri ~ "^/images") { break; }
if ( $request_uri ~ "^/tinymce") { break; }
if ( $request_uri ~ "^/install.php") { break; }
if ( $request_uri ~ "^/install_update.php") { break; }
if ( $request_uri ~ "^/captcha.php") { break; }
if ( $request_uri ~ "^/styles") { break; }
if ( $request_uri ~ "^/css") { break; }
if ( $request_uri ~ "\.css$") { break; }
if ( $request_uri ~ "^js") { break; }
if ( $request_uri ~ "^/js") { break; }
# если вы наблюдаете проблемы с compressed.js или compiled.js, закомментируйте следующую строку
#if ( $request_uri ~ "\.js$") { break; }
#if ( $request_uri ~ "^/webstat") { break; }
if (-e $request_filename) {
rewrite ^/(sys\-temp|cache|xmldb|static|packages)\/.*$ /500/ break;
}
if (!-e $request_filename) {
rewrite ^/robots\.txt /sbots.php?path=$1&$query_string last;
rewrite ^/sitemap\.xml /sitemap.php last;
rewrite ^(.*)\.xml$ /index.php?xmlMode=force&path=$1&$query_string last ;
rewrite ^/(udata|upage|uobject|ufs|usel|ulang|utype|umess|uhttp):?(\/\/)?(.*)$ /releaseStreams.php?scheme=$1&path=$3?$query_string last;
rewrite ^(.*)\.json$ /index.php?jsonMode=force&path=$1&%query_string last;
rewrite ^/.* /index.php?path=$fastcgi_script_name&$query_string last;
}
location / {
rewrite ^/~/([0-9]+)$ /tinyurl.php?id=$1 break;
root /home/website/website.ru/www;
index index.php;
}
location ~* (config\.ini|install\.ini|install\.log|umi\.nginx\.conf|dbview\.php|umibackup) {
rewrite ^(.*)$ / permanent;
}
location = /config.ini {
deny all;
}
#deny /classes access
location ^~ /classes {
deny all;
}
location ^~ /errors/logs/ {
deny all;
}
location ^~ /libs/ {
deny all;
}
location ^~ /sys-temp/ {
deny all;
}
location ^~ /tpls/ {
deny all;
}
location ^~ /umaps/ {
deny all;
}
location ^~ /usels/ {
deny all;
}
location ^~ /xsltTpls/ {
deny all;
}
location ^~ /styles/common/other/elfinder/php/ {
location ~.*\.(php)?$
{
deny all;
}
}
#disable php in /files/
location ~* /files/ { }
location ~* ^.+\.(php)$ {
root /home/website/website.ru/www;
fastcgi_pass unix:/tmp/php-website.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /website.ru/www$fastcgi_script_name;
include fastcgi_params;
fastcgi_connect_timeout 60;
fastcgi_send_timeout 180;
fastcgi_read_timeout 180;
fastcgi_buffer_size 32k;
fastcgi_buffers 4 32k;
fastcgi_busy_buffers_size 32k;
fastcgi_temp_file_write_size 32k;
fastcgi_temp_path /tmp;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/local/www/nginx-dist;
}
}