Last active
March 5, 2018 08:22
-
-
Save Snazzyham/f871e8549e2df1c8b718c7eac0cf2a5b to your computer and use it in GitHub Desktop.
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
| # an example nginx conf file for https using [this method](https://linode.com/docs/security/ssl/install-lets-encrypt-to-create-ssl-certificates/) | |
| server { | |
| listen 443; | |
| server_name example.com www.example.com; | |
| root /var/www/example.com/html; | |
| index index.php index.html index.htm index.nginx-debian.html; | |
| ssl on; | |
| ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem; | |
| ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem; | |
| # if hosting static or php files | |
| location / { | |
| try_files $uri $uri/ =404; | |
| } | |
| # if using proxy pass to other port on server | |
| location / { | |
| proxy_pass "http://127.0.0.1:5000" | |
| proxy_http_version 1.1; | |
| proxy_set_header Upgrade $http_upgrade; | |
| proxy_set_header Connection 'upgrade'; | |
| proxy_intercept_errors on; | |
| recursive_error_pages on; | |
| proxy_cache_bypass $http_upgrade; | |
| } | |
| # if needs rewrite to url | |
| location /api { | |
| rewrite ^/api/(.*) /$1 break; | |
| proxy_pass http://127.0.0.1:3000; | |
| } | |
| # make php work with nginx | |
| location ~ \.php$ { | |
| fascgi_split_path_info i^(.+\.php)(/.+)$; | |
| fastcgi_pass unix:/var/run/php/php5.6-fpm.sock; | |
| include snippets/fastcgi-php.conf; | |
| } | |
| } | |
| server { | |
| listen 80; | |
| server_name example.com wwww.example.com | |
| rewrite ^ https://$server_name$request_uri? permanent; | |
| } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment