Skip to content

Instantly share code, notes, and snippets.

@sekayasin
Created January 14, 2018 20:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sekayasin/6ac4420dd3a2dcb52adb0aa4e6735391 to your computer and use it in GitHub Desktop.
Save sekayasin/6ac4420dd3a2dcb52adb0aa4e6735391 to your computer and use it in GitHub Desktop.
here is my main nginx.conf
----------------------------------------------------------------------------------------------------
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;
include /usr/share/nginx/modules/*.conf;
events {
worker_connections 1024;
}
http {
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
client_max_body_size 200M;
include /etc/nginx/mime.types;
default_type application/octet-stream;
include /etc/nginx/conf.d/*.conf;
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name A.B.C.D;
root /usr/share/nginx/html;
index index.php index.html index.htm;
# Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf;
location / {
try_files $uri $uri/ /index.html;
}
error_page 404 /404.html;
location = /40x.html {
root /usr/share/nginx/html;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
location ~ .php$ {
try_files $uri = 404;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
}
----------------------------------------------------------------------------------------------------
Here is my webappA.com nginx config, in /etc/nginx/conf.d/webappA.conf
server {
listen 80;
listen [::]:80;
server_name webappA.com www.webappA.com;
root /usr/share/nginx/html/webappA;
index index.php index.html index.htm;
gzip on;
gzip_http_version 1.0;
gzip_disable "msie6";
gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;
location = /favicon.ico {
log_not_found off;
access_log off;
}
location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}
location / {
try_files $uri /index.php?$query_string; # For Drupal >= 7
}
location @rewrite {
rewrite ^/(.*)$ /index.php?q=$1;
}
error_page 404 /404.html;
location = /40x.html {
root /usrr/share/nginx/html/daniza;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html/daniza;
}
location ~ .php$ {
try_files $uri = 404;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
location ~ ^/sites/.*/files/styles/ { # For Drupal >= 7
try_files $uri @rewrite;
}
location ~ ^(/[a-z\-]+)?/system/files/ { # For Drupal >= 7
try_files $uri /index.php?$query_string;
}
location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
expires max;
log_not_found off;
}
location ~* /(?:.+)/files/styles/adaptive/(?:.+)$ {
if ( $http_cookie ~* "ais=(?<ais_cookie>[a-z0-9-_]+)" ) {
rewrite ^/(.+)/files/styles/adaptive/(.+)$ /$1/files/styles/$ais_cookie/$2 last;
}
access_log off;
add_header X-Header "AIS Generator 1.0";
set $nocache_details "Skip";
try_files $uri @drupal;
}
location ~* files/advagg_(?:css|js)/ {
access_log off;
expires max;
add_header ETag "";
add_header Cache-Control "max-age=2628000, no-transform, public";
try_files $uri $uri/ @rewrite;
}
listen 443 ssl; # managed by Certbot - This is fine! ssl_certificate omitted below
----------------------------------------------------------------------------------------------------
configs for webappB.com in /etc/nginx/conf.d/webappB.conf - same as for webappA, with only changes in the server_name and root.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment