Created
January 7, 2017 14:00
-
-
Save prinsss/9ccd6c2c1e9d976a516562e7dfbf38d4 to your computer and use it in GitHub Desktop.
Template for creating new nginx vhost.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| server { | |
| listen 443 ssl http2; | |
| server_name your-domain.com www.your-domain.com; | |
| index index.html index.htm index.php; | |
| # Let's Encrypt Certificate | |
| ssl_certificate /etc/letsencrypt/live/your-domain.com/fullchain.pem; | |
| ssl_certificate_key /etc/letsencrypt/live/your-domain.com/privkey.pem; | |
| ssl_session_timeout 10m; | |
| ssl_protocols TLSv1 TLSv1.1 TLSv1.2; | |
| ssl_prefer_server_ciphers on; | |
| ssl_ciphers ECDHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA256:ECDHE-RSA-AES256-SHA:!aNULL:!eNULL:!EXPORT:!DES:!3DES:!MD5:!RC4-SHA:!DSS:!PKS; | |
| # if ($host = www.your-domain.com) { | |
| # rewrite ^/(.*)$ $scheme://your-domain.com/$1 permanent; | |
| # } | |
| location ~ [^/]\.php(/|$) { | |
| fastcgi_pass unix:/dev/shm/php-cgi.sock; | |
| fastcgi_index index.php; | |
| include fastcgi.conf; | |
| } | |
| } | |
| server { | |
| listen 80; | |
| server_name your-domain.com www.your-domain.com; | |
| index index.html index.htm index.php; | |
| # For Let's Encrypt Challenges | |
| location /.well-known/acme-challenge/ { | |
| root /home/wwwroot/your-domain.com; | |
| allow all; | |
| } | |
| # Redirect HTTP requests to HTTPS | |
| # rewrite ^/(.*) https://$server_name/$1 permanent; | |
| location ~ [^/]\.php(/|$) { | |
| fastcgi_pass unix:/dev/shm/php-cgi.sock; | |
| fastcgi_index index.php; | |
| include fastcgi.conf; | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| server { | |
| listen 80; | |
| listen 443 ssl http2; | |
| index index.html index.htm index.php; | |
| root /home/wwwroot/your-domain.com; | |
| server_name your-domain.com; | |
| access_log off; | |
| location /.well-known/acme-challenge/ { | |
| root /home/wwwroot/your-domain.com; | |
| allow all; | |
| } | |
| ssl_certificate /etc/letsencrypt/live/your-domain.com/fullchain.pem; | |
| ssl_certificate_key /etc/letsencrypt/live/your-domain.com/privkey.pem; | |
| ssl_session_timeout 10m; | |
| ssl_protocols TLSv1 TLSv1.1 TLSv1.2; | |
| ssl_prefer_server_ciphers on; | |
| ssl_ciphers ECDHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA256:ECDHE-RSA-RC4-SHA:ECDHE-RSA-AES256-SHA:DHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA:RC4-SHA:!aNULL:!eNULL:!EXPORT:!DES:!3DES:!MD5:!DSS:!PKS; | |
| location ~ [^/]\.php(/|$) { | |
| fastcgi_pass unix:/dev/shm/php-cgi.sock; | |
| fastcgi_index index.php; | |
| include fastcgi.conf; | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|flv|ico)$ { | |
| expires 30d; | |
| access_log off; | |
| } | |
| location ~ .*\.(js|css)?$ { | |
| expires 7d; | |
| access_log off; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment