Skip to content

Instantly share code, notes, and snippets.

@wernerbihl
Created May 20, 2020 21:36
Show Gist options
  • Save wernerbihl/89efd603e4ff9d418626cf294b8a7ed8 to your computer and use it in GitHub Desktop.
Save wernerbihl/89efd603e4ff9d418626cf294b8a7ed8 to your computer and use it in GitHub Desktop.
Nginx
//Proxy Site
server {
listen 80 http2;
listen [::]:80 http2;
error_log /var/log/something-error.log warn;
index index.html index.htm;
server_name example.com;
location / {
proxy_pass http://127.0.0.1:6000;
}
gzip on;
gzip_proxied any;
gzip_types
text/css
text/javascript
application/javascript
application/json
text/xml
text/json;
}
// Normal Site
server {
listen 80 http2;
listen [::]:80 http2;
root /var/www;
index index.html index.htm index.nginx-debian.html;
server_name example.com www.example.com;
location / {
try_files $uri $uri/ =404;
}
gzip on;
gzip_proxied any;
gzip_types
text/css
text/javascript
application/javascript
application/json
text/xml
text/json;
}
// PHP Site
server {
listen 80;
listen [::]:80;
root /var/www;
index index.html index.php index.htm index.nginx-debian.html;
server_name example.com;
location / {
try_files $uri $uri/ =404;
}
location ~ \.php$ {
try_files $uri /index.php =404;
fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
gzip on;
gzip_proxied any;
gzip_types
text/css
text/javascript
application/javascript
application/json
text/xml
text/json;
}
//Enabling a site:
sudo ln -s /etc/nginx/sites-available/example.com /etc/nginx/sites-enabled/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment