Skip to content

Instantly share code, notes, and snippets.

@yoander
Last active February 5, 2017 21:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yoander/5e2659a2668779cf1c8086e96c767c64 to your computer and use it in GitHub Desktop.
Save yoander/5e2659a2668779cf1c8086e96c767c64 to your computer and use it in GitHub Desktop.
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_param REQUEST_URI $request_uri;
fastcgi_param DOCUMENT_URI $document_uri;
fastcgi_param DOCUMENT_ROOT $document_root;
fastcgi_param SERVER_PROTOCOL $server_protocol;
fastcgi_param REQUEST_SCHEME $scheme;
fastcgi_param HTTPS $https if_not_empty;
fastcgi_param GATEWAY_INTERFACE CGI/1.1;
fastcgi_param SERVER_SOFTWARE nginx/$nginx_version;
fastcgi_param REMOTE_ADDR $remote_addr;
fastcgi_param REMOTE_PORT $remote_port;
fastcgi_param SERVER_ADDR $server_addr;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_NAME $server_name;
# Mitigate https://httpoxy.org/ vulnerabilities
fastcgi_param HTTP_PROXY "";
# PHP only, required if PHP was built with --enable-force-cgi-redirect
fastcgi_param REDIRECT_STATUS 200;
# Default file will be requested
fastcgi_index index.php;
# Linked to fpm upstream name
fastcgi_pass fpm;
# Upstream to abstract backend connection(s) for PHP
# php-fpm is the docker container name where the php-fpm service is running.
# The NGINX server is running inside a docker container too and it's linked to
# php-fpm docker container.
upstream fpm {
server php-fpm:9000;
}
server {
listen 80;
server_name www.librebyte.net;
root /var/www/html/librebyte;
index index.php;
location = /favicon.ico {
log_not_found off;
access_log off;
}
location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}
# Add trailing slash to Wordpress Admin Panel requests, using
# full schema redirect due nginx is in a docker container with
# listen port = 80 and exposed port = 8080 (8080 -> 80)
rewrite /wp-admin$ $scheme://$http_host/wp-admin/ permanent;
location / {
# This is cool because no php is touched for static content.
# include the "?$args" part so non-default permalinks doesn't break when
# using query string
try_files $uri $uri/ /index.php?$args;
}
location ~ \.php$ {
include fastcgi.conf;
}
location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
expires max;
log_not_found off;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment