Skip to content

Instantly share code, notes, and snippets.

@sokolenkoDEV
Last active January 10, 2024 07:00
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save sokolenkoDEV/c2acad18632453c780e42469447ee128 to your computer and use it in GitHub Desktop.
Save sokolenkoDEV/c2acad18632453c780e42469447ee128 to your computer and use it in GitHub Desktop.
server {
listen 127.0.0.1:80;
ssi on;
gzip on;
gzip_comp_level 7;
gzip_types application/x-javascript application/javascript text/css;
server_name test.ru www.test.ru;
charset off;
#disable_symlinks if_not_owner from=$root_path;
index index.php;
root $root_path;
set $root_path /var/www/www-user/data/www/test;
set $php_sock unix:/var/www/php-fpm/www-user.sock;
access_log /var/www/httpd-logs/west-test.ru.access.log;
error_log /var/www/httpd-logs/west-test.ru.error.log notice;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
client_max_body_size 1024M;
client_body_buffer_size 4M;
#кому не надо убирать у домена www это не пишем. между http:// и test.ru убрать пробел, парсер дурит :)
if ($host = 'www.test.ru' ) {
rewrite ^(.*)$ http://test.ru$1 permanent;
}
location / {
try_files $uri $uri/ @bitrix;
}
location ~* /upload/.*\.(php|php3|php4|php5|php6|phtml|pl|asp|aspx|cgi|dll|exe|shtm|shtml|fcg|fcgi|fpl|asmx|pht|py|psp|rb|var)$ {
types {
text/plain text/plain php php3 php4 php5 php6 phtml pl asp aspx cgi dll exe ico shtm shtml fcg fcgi fpl asmx pht py psp rb var;
}
}
location ~ \.php$ {
try_files $uri @bitrix;
fastcgi_pass $php_sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PHP_ADMIN_VALUE "sendmail_path = /usr/sbin/sendmail -t -i -f admin@west-test.ru";
include fastcgi_params;
}
location @bitrix {
fastcgi_pass $php_sock;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root/bitrix/urlrewrite.php;
fastcgi_param PHP_ADMIN_VALUE "sendmail_path = /usr/sbin/sendmail -t -i -f admin@west-test.ru";
}
location ~* /bitrix/admin.+\.php$ {
try_files $uri @bitrixadm;
fastcgi_pass $php_sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PHP_ADMIN_VALUE "sendmail_path = /usr/sbin/sendmail -t -i -f admin@west-test.ru";
include fastcgi_params;
}
location @bitrixadm{
fastcgi_pass $php_sock;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root/bitrix/admin/404.php;
fastcgi_param PHP_ADMIN_VALUE "sendmail_path = /usr/sbin/sendmail -t -i -f admin@west-test.ru";
}
location = /favicon.ico {
log_not_found off;
access_log off;
}
location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}
#
# block this locations for any installation
#
# ht(passwd|access)
location ~* /\.ht { deny all; }
# repositories
location ~* /\.(svn|hg|git) { deny all; }
# bitrix internal locations
location ~* ^/bitrix/(modules|local_cache|stack_cache|managed_cache|php_interface) {
deny all;
}
# upload files
location ~* ^/upload/1c_[^/]+/ { deny all; }
# use the file system to access files outside the site (cache)
location ~* /\.\./ { deny all; }
location ~* ^/bitrix/html_pages/\.config\.php { deny all; }
location ~* ^/bitrix/html_pages/\.enabled { deny all; }
# Intenal locations
location ^~ /upload/support/not_image { internal; }
# Cache location: composite and general site
location ~* @.*\.html$ {
internal;
# disable browser cache, php manage file
expires -1y;
add_header X-Bitrix-Composite "Nginx (file)";
}
# Player options, disable no-sniff
location ~* ^/bitrix/components/bitrix/player/mediaplayer/player$ {
add_header Access-Control-Allow-Origin *;
}
# Accept access for merged css and js
location ~* ^/bitrix/cache/(css/.+\.css|js/.+\.js)$ {
expires 30d;
error_page 404 /404.html;
}
# Disable access for other assets in cache location
location ~* ^/bitrix/cache { deny all; }
# Use nginx to return static content from s3 cloud storage
# /upload/bx_cloud_upload/<schema>.<backet_name>.<s3_point>.amazonaws.com/<path/to/file>
location ^~ /upload/bx_cloud_upload/ {
location ~ ^/upload/bx_cloud_upload/(http[s]?)\.([^/:]+)\.(s3|s3-us-west-1|s3-eu-west-1|s3-ap-southeast-1|s3-ap-northeast-1)\.amazonaws\.com/(.+)$ {
internal;
resolver 8.8.8.8;
proxy_method GET;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Server $host;
#proxy_max_temp_file_size 0;
proxy_pass $1://$2.$3.amazonaws.com/$4;
}
location ~* .*$ { deny all; }
}
# Static content
location ~* ^/(upload|bitrix/images|bitrix/tmp) {
expires 30d;
}
location ~* \.(css|js|gif|png|jpg|jpeg|ico|ogg|ttf|woff|eot|otf)$ {
error_page 404 /404.html;
expires 30d;
}
location = /404.html {
access_log off ;
}
}
@adminnu
Copy link

adminnu commented Oct 19, 2018

Наш вариант конфигурационного файла, полный фарш:
1С-Битрикс + Nginx + php-fpm + композитный сайт

@Pahom-ka
Copy link

Наш вариант конфигурационного файла, полный фарш:
1С-Битрикс + Nginx + php-fpm + композитный сайт

Ага. С кучей косяков.

@yadvlz
Copy link

yadvlz commented Feb 17, 2021

Наш вариант конфигурационного файла, полный фарш:
1С-Битрикс + Nginx + php-fpm + композитный сайт

Ага. С кучей косяков.

Например?

@vasilcov77
Copy link

Наш вариант конфигурационного файла, полный фарш:
1С-Битрикс + Nginx + php-fpm + композитный сайт

Ага. С кучей косяков.

Например?

При установке ругнулся на 'no port in upstream "backend"'

@yadvlz
Copy link

yadvlz commented Feb 21, 2021

Наш вариант конфигурационного файла, полный фарш:
1С-Битрикс + Nginx + php-fpm + композитный сайт

Ага. С кучей косяков.

Например?

При установке ругнулся на 'no port in upstream "backend"'

Достаточно заменить "backend" на адрес php-fpm или определить upstream backend. Косяком это называть некорректно, т.к. в статье не описывается настройка php-fpm, но подсветить этот момент стоило бы, да.

@Vkavis
Copy link

Vkavis commented Apr 27, 2021

А есть вариант с переадресацией на SSL?

@yadvlz
Copy link

yadvlz commented Apr 27, 2021

Добавьте
server {
listen 80;
server_name example.com;
return 301 https://$host$request_uri;
}
и в конфиге выше настройте ssl.

@Vkavis
Copy link

Vkavis commented Apr 27, 2021

Добавьте
server {
listen 80;
server_name example.com;
return 301 https://$host$request_uri;
}
и в конфиге выше настройте ssl.
Спасибо!

fastcgi_param PHP_ADMIN_VALUE "sendmail_path = /usr/sbin/sendmail -t -i -f admin@west-test.ru";
А, что это за почта здесь, что на нее будет приходить. Почта же в админке битрикса прописывается?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment