-
-
Notifications
You must be signed in to change notification settings - Fork 436
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Convert dev environment to use more secure nginx+fpm configuration wi…
…th split admin/frontend urls.
- Loading branch information
1 parent
7974e12
commit d43c337
Showing
9 changed files
with
168 additions
and
10 deletions.
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,57 @@ | ||
server { | ||
listen 80; | ||
server_name _ ""; | ||
|
||
if ( $request_method !~ ^(GET|POST|HEAD|OPTIONS)$) { return 405; } | ||
|
||
set $fastcgi_script_filename ""; # Required because it is used in a log format | ||
set $fastcgi_php_value ""; # Pre/Append to add more PHP FPM config | ||
|
||
location / { | ||
root /var/www/html/dev/openmage/pub/${NGINX_MAGE_RUN_CODE}; # Only files in this directory can be loaded directly | ||
set $fastcgi_script_filename /var/www/html/index.php; # Hard-coded to prevent loading other PHP files | ||
try_files $uri @php-fpm; | ||
} | ||
|
||
location /skin/ { | ||
root /var/www/html; | ||
gzip on; | ||
location ~* \.(eot|ttf|otf|woff|woff2|svg)$ { | ||
add_header Access-Control-Allow-Origin "*"; | ||
} | ||
} | ||
location /media/ { | ||
root /var/www/html; | ||
gzip on; | ||
location ~* \.(eot|ttf|otf|woff|woff2|svg)$ { | ||
add_header Access-Control-Allow-Origin "*"; | ||
} | ||
# TODO - support get.php | ||
} | ||
location /js/ { | ||
root /var/www/html; | ||
# TODO - support js/index.php? | ||
} | ||
location /errors/ { | ||
root /var/www/html; | ||
location ~* \.(!(css|jpg|jpeg|gif|png|ico))$ { return 404; } | ||
} | ||
# TODO - support api.php | ||
|
||
# Proxy the PHP scripts to PHP FPM listening | ||
location @php-fpm { | ||
root /var/www/html; | ||
fastcgi_pass php-fpm:9000; | ||
include fastcgi_params; | ||
fastcgi_param SCRIPT_FILENAME $fastcgi_script_filename; | ||
fastcgi_param SERVER_PORT '80'; | ||
fastcgi_param MAGE_RUN_CODE ${NGINX_MAGE_RUN_CODE}; | ||
fastcgi_param MAGE_RUN_TYPE ${NGINX_MAGE_RUN_TYPE}; | ||
fastcgi_param PHP_VALUE "error_log=\"/var/www/html/var/log/php_errors-${NGINX_MAGE_RUN_CODE}.log\"\n$fastcgi_php_value"; | ||
|
||
# FastCGI tuning parameters | ||
fastcgi_connect_timeout 6s; | ||
fastcgi_send_timeout 60s; | ||
fastcgi_read_timeout 20m; | ||
} | ||
} |
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,59 @@ | ||
server { | ||
listen 80; | ||
server_name _ ""; | ||
|
||
if ( $request_method !~ ^(GET|POST|HEAD|OPTIONS)$) { return 405; } | ||
|
||
set $fastcgi_script_filename ""; # Required because it is used in a log format | ||
set $fastcgi_php_value ""; # Pre/Append to add more PHP FPM config | ||
|
||
location / { | ||
root /var/www/html/dev/openmage/pub/${NGINX_MAGE_RUN_CODE}; # Only files in this directory can be loaded directly | ||
set $fastcgi_script_filename /var/www/html/index.php; # Hard-coded to prevent loading other PHP files | ||
try_files $uri @php-fpm; | ||
} | ||
|
||
location /skin/ { | ||
root /var/www/html; | ||
gzip on; | ||
location ~* \.(eot|ttf|otf|woff|woff2|svg)$ { | ||
add_header Access-Control-Allow-Origin "*"; | ||
} | ||
} | ||
location /media/ { | ||
root /var/www/html; | ||
gzip on; | ||
location ~* \.(eot|ttf|otf|woff|woff2|svg)$ { | ||
add_header Access-Control-Allow-Origin "*"; | ||
} | ||
# TODO - support get.php | ||
} | ||
location /js/ { | ||
root /var/www/html; | ||
} | ||
location /errors/ { | ||
root /var/www/html; | ||
location ~* \.(!(css|jpg|jpeg|gif|png|ico))$ { return 404; } | ||
} | ||
|
||
# Admin is disabled for frontend config | ||
location /index.php/ { return 404; } | ||
location /admin/ { return 404; } | ||
|
||
# Proxy the PHP scripts to PHP FPM listening | ||
location @php-fpm { | ||
root /var/www/html; | ||
fastcgi_pass php-fpm:9000; | ||
include fastcgi_params; | ||
fastcgi_param SCRIPT_FILENAME $fastcgi_script_filename; | ||
fastcgi_param SERVER_PORT '80'; | ||
fastcgi_param MAGE_RUN_CODE ${NGINX_MAGE_RUN_CODE}; | ||
fastcgi_param MAGE_RUN_TYPE ${NGINX_MAGE_RUN_TYPE}; | ||
fastcgi_param PHP_VALUE "error_log=\"/var/www/html/var/log/php_errors-${NGINX_MAGE_RUN_CODE}.log\"\n$fastcgi_php_value"; | ||
|
||
# FastCGI tuning parameters | ||
fastcgi_connect_timeout 6s; | ||
fastcgi_send_timeout 60s; | ||
fastcgi_read_timeout 20m; | ||
} | ||
} |
Binary file not shown.
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,2 @@ | ||
User-Agent: * | ||
Disallow: / |
Binary file not shown.
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,2 @@ | ||
User-Agent: * | ||
Disallow: |