Skip to content

Commit 89f82b3

Browse files
committed
fix: Simple config update
- single nginx server - ssl offload - adjust for docker
1 parent 27000d0 commit 89f82b3

File tree

10 files changed

+65
-67
lines changed

10 files changed

+65
-67
lines changed
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
1+
## Admin location config
22
location ~ ^/(index.php/)?${ADMIN_PATH} {
33

44
include ipset/allow.conf;
55
deny all;
66

7-
proxy_pass http://varnish;
7+
try_files $uri $uri/ /index.php$is_args$args;
88
}

magento2/conf_m2/cors.conf

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
if ($request_method = 'OPTIONS') {
2-
add_header 'Access-Control-Allow-Origin' '$cors_origin';
3-
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
4-
add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range';
5-
add_header 'Access-Control-Max-Age' 1728000;
6-
add_header 'Content-Type' 'text/plain; charset=utf-8';
7-
add_header 'Content-Length' 0;
2+
add_header 'Access-Control-Allow-Origin' $cors_origin always;
3+
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS' always;
4+
add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range' always;
5+
add_header 'Access-Control-Max-Age' 1728000 always;
6+
add_header 'Content-Type' 'text/plain; charset=utf-8' always;
7+
add_header 'Content-Length' 0 always;
88
return 204;
99
}
1010
if ($request_method = 'POST') {
11-
add_header 'Access-Control-Allow-Origin' '$cors_origin';
12-
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
13-
add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range';
14-
add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range';
11+
add_header 'Access-Control-Allow-Origin' $cors_origin always;
12+
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS' always;
13+
add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range' always;
14+
add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range' always;
1515
}
1616
if ($request_method = 'GET') {
17-
add_header 'Access-Control-Allow-Origin' '$cors_origin';
18-
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
19-
add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range';
20-
add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range';
17+
add_header 'Access-Control-Allow-Origin' $cors_origin always;
18+
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS' always;
19+
add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range' always;
20+
add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range' always;
2121
}

magento2/conf_m2/maps.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ map $request $writelog {
3333
## CORS headers
3434
map $http_origin $cors_origin {
3535
default "";
36-
~*.${DOMAIN}$ "$http_origin";
36+
~*.${DOMAIN}$ $http_origin;
3737
}
3838

3939
## Location http auth

magento2/conf_m2/media.conf

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,10 @@ location /media/ {
4444
location ~* \.(jpg|jpeg|png|webp|gif|svg|swf|eot|ttf|otf|woff|woff2|js|css|ico|txt)$ {
4545
expires max;
4646
add_header Cache-Control "public";
47-
proxy_pass http://nginx;
47+
try_files $uri $uri/ @media;
4848
}
4949
## Default media handler for other files
50-
proxy_pass http://nginx;
50+
try_files $uri $uri/ @media;
5151
}
5252

53-
53+
location @media { try_files $uri $uri/ /get.php$is_args$args; }

magento2/conf_m2/php_backend.conf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,16 @@
22
## specific security and compatibility headers
33
add_header X-Magenx-Config 'MagenX -= www.magenx.com =-' always;
44
add_header X-Request-Time $request_time always;
5-
add_header X-Request-ID $http_x_request_id always;
5+
add_header X-Request-ID $request_id always;
66
add_header Strict-Transport-Security "max-age=31556926; includeSubDomains; preload" always;
77
add_header Referrer-Policy "strict-origin-when-cross-origin" always;
8-
add_header X-UA-Compatible 'IE=Edge,chrome=1';
98

109
## php backend settings
1110
fastcgi_pass $mage_php_route;
1211
fastcgi_index index.php;
1312

1413
fastcgi_keep_conn on;
14+
# fastcgi_intercept_errors on;
1515
include fastcgi_params;
1616

1717
## Enable Magento profiler

magento2/conf_m2/extra_protect.conf renamed to magento2/conf_m2/protect.conf

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,44 +21,44 @@ location ~ ^/((fire|one.+)?checkout|magewire)/ {
2121
if ($cookie_form_key = "") { return 403; }
2222
limit_req zone=checkout burst=8;
2323
limit_req_status 429;
24-
proxy_pass http://nginx;
24+
try_files $uri $uri/ /index.php$is_args$args;
2525
}
2626

2727
location ~ ^/(wishlist|customer)/ {
2828
if ($search_bot) { return 410; }
2929
limit_req zone=customer burst=4;
3030
limit_req_status 429;
31-
proxy_pass http://nginx;
31+
try_files $uri $uri/ /index.php$is_args$args;
3232
}
3333

3434
location ~ ^/(productalert|outofstocknotification|newsletter|sendfriend|catalog/product_compare|sales/guest/view|contact/index/post|review/product/post)/ {
3535
if ($search_bot) { return 410; }
3636
if ($cookie_form_key = "") { return 403; }
3737
limit_req zone=catalog burst=4;
3838
limit_req_status 429;
39-
proxy_pass http://nginx;
39+
try_files $uri $uri/ /index.php$is_args$args;
4040
}
4141

4242
location ~ ^/(catalog)?search/(searchTermsLog|result|ajax.+ges?t)/ {
4343
if ($search_bot) { return 410; }
4444
if ($cookie_form_key = "") { return 403; }
4545
limit_req zone=search burst=4;
4646
limit_req_status 429;
47-
proxy_pass http://nginx;
47+
try_files $uri $uri/ /index.php$is_args$args;
4848
}
4949

5050
location ~ /V1/guest-carts/(?<cartId>.+)/payment-information {
5151
if ($search_bot) { return 410; }
5252
if ($cookie_form_key = "") { return 403; }
5353
limit_req zone=payment;
5454
limit_req_status 429;
55-
proxy_pass http://nginx;
55+
try_files $uri $uri/ /index.php$is_args$args;
5656
}
5757

5858
location ~ ^/(soap|rest|V1)/ {
5959
if ($search_bot) { return 410; }
6060
if ($cookie_form_key = "") { return 403; }
6161
limit_req zone=api;
6262
limit_req_status 429;
63-
proxy_pass http://nginx;
63+
try_files $uri $uri/ /index.php$is_args$args;
6464
}

magento2/conf_m2/sitemap.conf

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
1-
location ^/(robots\.txt|google.*\.html) { root $root_path/pub/media/seo; }
2-
location ~ ^/feeds/.*\.(xml|csv|txt) { root $root_path/pub/media; }
1+
2+
location ^/(robots\.txt|google.*\.html) {
3+
root $root_path/pub/media/seo;
4+
}
5+
6+
location ~ ^/feeds/.*\.(xml|csv|txt) {
7+
root $root_path/pub/media;
8+
}
39

410
location = /sitemap.xml {
511
root $root_path/pub/media/sitemap;

magento2/services/phpmyadmin.conf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,8 @@ location ~ ^/${PHPMYADMIN_PATH}/(.*)$ {
55
deny all;
66

77
proxy_pass http://phpmyadmin/$1$is_args$args;
8+
9+
add_header Cache-Control "no-store, no-cache, must-revalidate, proxy-revalidate, max-age=0" always;
10+
add_header Pragma "no-cache" always;
11+
add_header Expires 0 always;
812
}

magento2/services/rabbitmq.conf

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
## RabbitMQ configuration
22
location ~ ^/${RABBITMQ_PATH}/(.*)$ {
3-
4-
include ipset/allow.conf;
5-
deny all;
6-
7-
proxy_pass http://rabbitmq/$1$is_args$args;
8-
}
3+
include ipset/allow.conf;
4+
deny all;
5+
6+
proxy_pass http://rabbitmq/$1$is_args$args;
7+
8+
add_header Cache-Control "no-store, no-cache, must-revalidate, proxy-revalidate, max-age=0" always;
9+
add_header Pragma "no-cache" always;
10+
add_header Expires 0 always;
11+
}

magento2/sites-available/magento2.conf

Lines changed: 16 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ include conf_m2/maps.conf;
44
## Certbot renew
55
# include conf_m2/certbot_renew.conf;
66

7-
## Proxy server to apply filters and rules
87
server {
98
listen nginx:80;
109
server_name ${DOMAIN};
@@ -26,46 +25,33 @@ server {
2625
if ($deny_ip) { return 403; }
2726
if ($bad_user_agent) { return 403; }
2827

29-
## Server maintenance block.
30-
include conf_m2/maintenance.conf;
31-
32-
## phpMyAdmin configuration
33-
include services/phpmyadmin.conf;
34-
35-
## Rabbitmq configuration
36-
include services/rabbitmq.conf;
37-
3828
## Extra protection rules
39-
include conf_m2/extra_protect.conf;
40-
29+
include conf_m2/protect.conf;
30+
4131
## Protect admin path
42-
include conf_m2/admin_protect.conf;
43-
32+
include conf_m2/admin.conf;
33+
4434
## Error log/page
45-
# include conf_m2/error_page.conf;
35+
# include conf_m2/error_page.conf;
4636

37+
## Server maintenance block.
38+
include conf_m2/maintenance.conf;
39+
4740
## sitemap and feeds?
4841
include conf_m2/sitemap.conf;
4942

5043
## Static files push only
5144
include conf_m2/static.conf;
5245

5346
## Product images and all media/ files
54-
include conf_m2/media.conf;
55-
56-
## Proxy-pass to backend
57-
location / {
58-
proxy_pass http://nginx;
59-
}
60-
}
61-
62-
## Backend server
63-
server {
64-
listen nginx:8080;
65-
server_name ${DOMAIN};
66-
67-
root $root_path/pub;
68-
47+
include conf_m2/media.conf;
48+
49+
## phpMyAdmin configuration
50+
include services/phpmyadmin.conf;
51+
52+
## Rabbitmq configuration
53+
include services/rabbitmq.conf;
54+
6955
## Nginx and php-fpm status
7056
include conf_m2/status.conf;
7157

@@ -82,7 +68,6 @@ server {
8268
location ~ ^/(index|health_check|get|static|errors/(report|404|503))\.php$ {
8369
try_files $uri =404;
8470
include conf_m2/php_backend.conf;
85-
# fastcgi_intercept_errors on;
8671

8772
## Enable POST logging
8873
# if ($request_method = POST) {set $ispostlog A;}

0 commit comments

Comments
 (0)