Skip to content

Instantly share code, notes, and snippets.

@finagin
Created March 22, 2018 13:12
Show Gist options
  • Save finagin/73df895561c42f943663074885258f98 to your computer and use it in GitHub Desktop.
Save finagin/73df895561c42f943663074885258f98 to your computer and use it in GitHub Desktop.
#!/usr/bin/env php
<?php
$domain = 'amobeeline';
$nginx = <<<CONF
server {
listen 80;
listen 443 ssl;
ssl on;
ssl_certificate /etc/nginx/ssl/$domain/bundle.crt;
ssl_certificate_key /etc/nginx/ssl/$domain/server_private.key;
server_name *.$domain.ru;
set \$build 'www';
if (\$host ~ "([^\.]+)\.$domain\.ru$") {
set \$build $1;
}
if (!-f /projects/$domain/\$build/.env) {
set \$build 'www';
}
root /projects/$domain/\$build/current/public;
add_header X-Frame-Options "SAMEORIGIN";
add_header X-XSS-Protection "1; mode=block";
add_header X-Content-Type-Options "nosniff";
index index.html index.htm index.php;
charset utf-8;
location / {
try_files \$uri \$uri/ /index.php?\$query_string;
}
location = /favicon.ico { access_log off; log_not_found off; }
location = /robots.txt { access_log off; log_not_found off; }
error_page 404 /index.php;
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/run/php/php7.1-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME \$document_root\$fastcgi_script_name;
fastcgi_param HTTPS off;
}
location ~ /\.(?!well-known).* {
deny all;
}
}
CONF;
echo $nginx or die(1);
die(0);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment