Last active
October 24, 2019 14:57
-
-
Save geekish/237a4182ba669eb36f520255147e735d to your computer and use it in GitHub Desktop.
Nginx configuration
This file contains 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
# Default server, with a "hello world" page & phpinfo. | |
server { | |
listen 80 default; | |
server_name localhost; | |
root /usr/local/var/www/default; | |
index index.php; | |
error_log /usr/local/var/log/nginx/default.error.log; | |
location / { | |
allow 127.0.0.1; | |
allow 192.168.1.0/24; | |
deny all; | |
try_files $uri $uri/ /index.php?$query_string; | |
} | |
include /usr/local/etc/nginx/inc/ignore.conf; | |
include /usr/local/etc/nginx/inc/php.conf; | |
} |
This file contains 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
# Just an example, I don't use as much as I used to, but it can be handy. | |
server { | |
listen 80; | |
server_name ~^(?<sname>.+?).example.test$; | |
root /usr/local/var/www/example/$sname/public; | |
index index.php; | |
error_log /usr/local/etc/nginx/logs/backup.error.log debug; | |
access_log /usr/local/etc/nginx/logs/backup.access.log main; | |
location / { | |
allow 127.0.0.1; | |
allow 192.168.1.0/24; | |
deny all; | |
try_files $uri $uri/ /index.php?$query_string; | |
} | |
include /usr/local/etc/nginx/inc/ignore.conf; | |
include /usr/local/etc/nginx/inc/php.conf; | |
} |
This file contains 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 ~ /(?!.well-known)(\.)\w+ { | |
deny all; | |
} | |
location ^~ /.well-known/acme-challenge/ { | |
allow all; | |
} | |
location = /favicon.ico { | |
log_not_found off; | |
access_log off; | |
} | |
location = /robots.txt { | |
allow all; | |
log_not_found off; | |
access_log off; | |
} |
This file contains 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 ~ \.php$ { | |
try_files $uri = 404; | |
fastcgi_pass 127.0.0.1:9000; | |
fastcgi_index index.php; | |
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; | |
include fastcgi_params; | |
} |
This file contains 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
user _www _www; | |
worker_processes 1; | |
error_log /usr/local/var/log/nginx/error.log; | |
events { | |
worker_connections 1024; | |
} | |
http { | |
include mime.types; | |
default_type application/octet-stream; | |
log_format main '$remote_addr - $remote_user [$time_local] "$request" ' | |
'$status $body_bytes_sent "$http_referer" ' | |
'"$http_user_agent" "$http_x_forwarded_for"'; | |
sendfile on; | |
keepalive_timeout 65; | |
include conf.d/*.conf; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment