Skip to content

Instantly share code, notes, and snippets.

@kennyhorna
Created May 22, 2018 01:01
Show Gist options
  • Save kennyhorna/0776ebeb0a091b4a1ac7f354c8e3a23a to your computer and use it in GitHub Desktop.
Save kennyhorna/0776ebeb0a091b4a1ac7f354c8e3a23a to your computer and use it in GitHub Desktop.
server_name XXX.XXX.XXX.XXX www.mydomain.app mydomain.app prod.mydomain.app;
location /phpmyadmin {
root /usr/share/;
index index.php index.html index.htm;
location ~ ^/phpmyadmin/(.+\.php)$ {
try_files $uri =404;
root /usr/share/;
fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
location ~* ^/phpmyadmin/(.+\.(jpg|jpeg|gif|css|png|js|ico|html|xml|txt))$ {
root /usr/share/;
}
}
location /phpMyAdmin {
rewrite ^/* /phpmyadmin last;
}
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ /index.php?$query_string;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php7.0-fpm.sock;
}
location ~ /\.ht {
deny all;
}
listen [::]:443 ssl ipv6only=on; # managed by Certbot
listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/www.mydomain.app/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/www.mydomain.app/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/mydomainssl-dhparams.pem; # managed by Certbot
server {
if ($host = mydomain.app) {
return 301 https://$host$request_uri;
} # managed by Certbot
if ($host = www.mydomain.app) {
return 301 https://$host$request_uri;
} # managed by Certbot
if ($host = prod.mydomain.app) {
return 301 https://$host$request_uri;
} # managed by Certbot
listen 80 default_server;
listen [::]:80 default_server;
server_name XXX.XXX.XXX.XXX www.mydomain.app mydomain.app prod.mydomain.app;
return 404; # managed by Certbot
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment