-
Notifications
You must be signed in to change notification settings - Fork 26
Move nginx config to mustache #14
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
d3e6ff7
Generate config files from mustache
kirtangajjar 884542a
Add mustache tags in env file
kirtangajjar 9914b6b
Remove commented code
kirtangajjar 28456a3
Update PR according to feedback
kirtangajjar 3cddf15
Rename ee4 in config to ee
kirtangajjar 435cb10
Convert WP config templates to a single block
kirtangajjar a5404db
Corrected changes in phar
kirtangajjar a218825
Correct config changes
kirtangajjar 0b4c3d4
Convert php.ini to mustache
kirtangajjar File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
MYSQL_ROOT_PASSWORD={{root_password}} | ||
MYSQL_DATABASE={{database_name}} | ||
MYSQL_USER={{database_user}} | ||
MYSQL_PASSWORD={{user_password}} | ||
|
||
WORDPRESS_DB_HOST={{wp_db_host}} | ||
VIRTUAL_HOST={{virtual_host}} | ||
VIRTUAL_HOST_EMAIL=example@{{virtual_host}} | ||
USER_ID={{user_id}} | ||
GROUP_ID={{group_id}} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,185 @@ | ||
# Add your custom config in custom.conf | ||
# ALL CHANGES IN THIS FILE WILL BE LOST AFTER EasyEngine Update | ||
|
||
server { | ||
access_log /var/log/nginx/access.log; | ||
error_log /var/log/nginx/error.log; | ||
|
||
root /var/www/html; | ||
|
||
server_name {{server_name}}; | ||
|
||
index index.php index.html index.htm; | ||
|
||
{{#include_redis_conf}} | ||
# Redis NGINX CONFIGURATION | ||
set $skip 0; | ||
# POST requests and URL with a query string should always go to php | ||
if ($request_method = POST) { | ||
set $skip 1; | ||
} | ||
if ($query_string != "") { | ||
set $skip 1; | ||
} | ||
# Don't cache URL containing the following segments | ||
if ($request_uri ~* "(/wp-admin/|/xmlrpc.php|wp-.*.php|index.php|/feed/|sitemap(_index)?.xml|[a-z0-9_-]+-sitemap([0-9]+)?.xml)") { | ||
set $skip 1; | ||
} | ||
# Don't use the cache for logged in users or recent commenter or customer with items in cart | ||
if ($http_cookie ~* "comment_author|wordpress_[a-f0-9]+|wp-postpass|wordpress_no_cache|wordpress_logged_in|woocommerce_items_in_cart") { | ||
set $skip 1; | ||
} | ||
# Use cached or actual file if they exists, Otherwise pass request to WordPress | ||
location / { | ||
try_files $uri $uri/ /index.php?$args; | ||
} | ||
|
||
location /redis-fetch { | ||
internal ; | ||
set $redis_key $args; | ||
redis_pass ee_redis:6379; | ||
} | ||
location /redis-store { | ||
internal ; | ||
set_unescape_uri $key $arg_key ; | ||
redis2_query set $key $echo_request_body; | ||
redis2_query expire $key 14400; | ||
redis2_pass ee_redis:6379; | ||
} | ||
|
||
location ~ \.php$ { | ||
# add_header Cache-Control "max-age=0, no-cache, no-store, must-revalidate"; | ||
set $key "nginx-cache:$scheme$request_method$host$request_uri"; | ||
try_files $uri =404; | ||
|
||
srcache_fetch_skip $skip; | ||
srcache_store_skip $skip; | ||
|
||
srcache_response_cache_control off; | ||
|
||
set_escape_uri $escaped_key $key; | ||
|
||
srcache_fetch GET /redis-fetch $key; | ||
srcache_store PUT /redis-store key=$escaped_key; | ||
|
||
more_set_headers 'X-SRCache-Fetch-Status $srcache_fetch_status'; | ||
more_set_headers 'X-SRCache-Store-Status $srcache_store_status'; | ||
|
||
include fastcgi_params; | ||
fastcgi_pass php:9000; | ||
} | ||
|
||
{{/include_redis_conf}} | ||
|
||
{{#include_wpsubdir_conf}} | ||
# WPSUBDIRECTORY NGINX CONFIGURATION | ||
if (!-e $request_filename) { | ||
|
||
# Redirect wp-admin to wp-admin/ | ||
rewrite /wp-admin$ $scheme://$host$uri/ permanent; | ||
|
||
# Redirect wp-* files/folders | ||
rewrite ^(/[^/]+)?(/wp-.*) $2 last; | ||
|
||
# Redirect other php files | ||
rewrite ^(/[^/]+)?(/.*\.php) $2 last; | ||
} | ||
{{/include_wpsubdir_conf}} | ||
|
||
{{#include_php_conf}} | ||
# PHP NGINX CONFIGURATION | ||
location / { | ||
try_files $uri $uri/ /index.php?$args; | ||
} | ||
location ~ \.php$ { | ||
try_files $uri =404; | ||
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; | ||
include fastcgi_params; | ||
fastcgi_pass php:9000; | ||
} | ||
{{/include_php_conf}} | ||
|
||
{{! wpcommon.conf }} | ||
# WordPress COMMON SETTINGS | ||
# Limit access to avoid brute force attack | ||
location = /wp-login.php { | ||
limit_req zone=one burst=1 nodelay; | ||
include fastcgi_params; | ||
fastcgi_pass php:9000; | ||
} | ||
# Disable wp-config.txt | ||
location = /wp-config.txt { | ||
deny all; | ||
access_log off; | ||
log_not_found off; | ||
} | ||
# Disallow php in upload folder | ||
location /wp-content/uploads/ { | ||
location ~ \.php$ { | ||
#Prevent Direct Access Of PHP Files From Web Browsers | ||
deny all; | ||
} | ||
} | ||
{{! /wpcommon.conf }} | ||
|
||
{{! locations.conf }} | ||
# NGINX CONFIGURATION FOR COMMON LOCATION | ||
# Basic locations files | ||
location = /favicon.ico { | ||
access_log off; | ||
log_not_found off; | ||
expires max; | ||
} | ||
|
||
location = /robots.txt { | ||
# Some WordPress plugin gererate robots.txt file | ||
# Refer #340 issue | ||
try_files $uri $uri/ /index.php?$args; | ||
access_log off; | ||
log_not_found off; | ||
} | ||
# Cache static files | ||
location ~* \.(ogg|ogv|svg|svgz|eot|otf|woff|mp4|ttf|rss|atom|jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz2|doc|xls|exe|ppt|tar|mid|midi|wav|bmp|rtf|swf)$ { | ||
add_header "Access-Control-Allow-Origin" "*"; | ||
access_log off; | ||
log_not_found off; | ||
expires max; | ||
} | ||
# Security settings for better privacy | ||
# Deny hidden files | ||
location /.well-known { | ||
allow all; | ||
} | ||
location ~ /\. { | ||
deny all; | ||
access_log off; | ||
log_not_found off; | ||
} | ||
# Deny backup extensions & log files | ||
location ~* ^.+\.(bak|log|old|orig|original|php#|php~|php_bak|save|swo|swp|sql)$ { | ||
deny all; | ||
access_log off; | ||
log_not_found off; | ||
} | ||
# Return 403 forbidden for readme.(txt|html) or license.(txt|html) or example.(txt|html) | ||
if ($uri ~* "^.+(readme|license|example)\.(txt|html)$") { | ||
return 403; | ||
} | ||
# Status pages | ||
location /nginx_status { | ||
stub_status on; | ||
access_log off; | ||
} | ||
location ~ ^/(status|ping) { | ||
include fastcgi_params; | ||
fastcgi_pass php:9000; | ||
} | ||
location ~* \.(css|js)$ { | ||
expires 1d; | ||
add_header Cache-Control "public, must-revalidate"; | ||
} | ||
|
||
{{! /locations.conf }} | ||
|
||
client_max_body_size 100m; | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# Custom PHP settings | ||
|
||
upload_max_filesize = 100M | ||
post_max_size = 100M | ||
|
||
[mail function] | ||
sendmail_path = /usr/sbin/sendmail -S mail:1025 |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kirtangajjar remove this
location
block at all. A 5s cache is no useful.Is there way we add
--env
check? In dev env this block should not exist. In production, this can exist with longer expiry.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dev env will be handled in beta2. Please assume all config is for prod. We'll add flag as well as separate config for dev in next release. @rahul286
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok for production, make 5s atleadt 1d.