Skip to content

Instantly share code, notes, and snippets.

@IkarosKappler
Created December 4, 2017 19:09
Show Gist options
  • Save IkarosKappler/482cd87315cc316147cf568ab31c742b to your computer and use it in GitHub Desktop.
Save IkarosKappler/482cd87315cc316147cf568ab31c742b to your computer and use it in GitHub Desktop.
Configuration | Nginx user_dir public_html with PHP execution (+fastCGI)
server {
listen 80;
listen [::]:80 default_server ipv6only=on;
server_name _;
root /usr/share/nginx/www;
index index.php index.html index.htm;
# Deny access to all dotfiles
location ~ /\. {
deny all;
}
location ~ \.php$ {
include /etc/nginx/fastcgi_params;
try_files $uri = 404; # Prevents exploit
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
}
# Serve user directories
location ~ ^/~(.+?)(/.*)?$ {
alias /home/$1/public_html$2;
autoindex on;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment