nginx
nginx copied to clipboard
Directives from the nocache.map file do not work.
Directives from the nocache.map file do not work.
Are you using the sample directives as is? Did you change anything? What does "not work" mean? Do you have any error logs? Not enough information to begin to troubleshoot.
I test it on a local computer in Windows 10
- In the beginning I created an image with the new Nginx
docker build --build-arg "NGINX_VERSION=1.21.6" -t openbridge/nginx .
- My docker-compose.yml :
version: '3.2'
services:
nginx:
image: openbridge/nginx:latest
container_name: novalnet-nginx
hostname: novalnet-nginx
depends_on:
- redis
ports:
- 80:80
- 443:443
tty: true
volumes:
- logs:/var/log/nginx:ro
- ${LOG_DIR}/nginx:/var/log/nginx #Local log dir.
- ${CONF_DIR}/nginx/docker.novalnet.local/nginx.conf:/etc/nginx/nginx.conf:ro #Configurations.
- ${CONF_DIR}/nginx/docker.novalnet.local/sites-available/novalnet.conf:/etc/nginx/sites-available/novalnet.conf:ro #Host Configurations.
- ${CONF_DIR}/nginx/docker.novalnet.local/map.d/nocache/nocache.map:/etc/nginx/map.d/nocache/nocache.map:ro #No cache by url.
- cdir:/var/cache:rw #Global cache dir.
- ${HOME_DIR}:/usr/share/nginx/html #Home directory
ulimits:
nproc: 65535
nofile:
soft: 49999
hard: 99999
env_file:
- .env
links:
- php
- redis
restart: unless-stopped
networks:
grf:
ipv4_address: 172.20.1.4
redis:
image: redis:alpine
container_name: redis
restart: always
ports:
- "6379:6379"
networks:
grf:
ipv4_address: 172.20.1.9
php:
container_name: novalnet-php
hostname: novalnet-php
build:
context: ${BUILD_DIR}/php-fpm8
dockerfile: Dockerfile
args:
PHP_V: ${PHP_VER}
ports:
- "9000:9000"
volumes:
- ${CONF_DIR}/php/php.ini:/usr/local/etc/php/conf.d/php.ini:ro
- logs:/var/log:ro
- ${LOG_DIR}/php:/var/log:ro
- ${CONF_DIR}/wp/wp-config.php:/usr/share/nginx/html/wp-config.php:rw
- cdir:/var/cache:rw
- ${HOME_DIR}:/usr/share/nginx/html
- ${HOME_DIR}/cache:/var/cache:rw
env_file:
- .env
cap_add:
- SYS_NICE
- DAC_READ_SEARCH
restart: unless-stopped
environment:
WORDPRESS_DB_HOST: ${WORDPRESS_DB_HOST}
WORDPRESS_DB_USER: ${WORDPRESS_DB_USER}
WORDPRESS_DB_PASSWORD: ${WORDPRESS_DB_PASSWORD}
WORDPRESS_DB_NAME: ${WORDPRESS_DB_NAME}
links:
- nmysql
networks:
grf:
ipv4_address: 172.20.1.5
nmysql:
image: mysql:${MYSQL_VER}
container_name: novalnet-mysql
hostname: nmysql
command: --default-authentication-plugin=mysql_native_password
env_file:
- .env
ports:
- "3306:3306"
volumes:
- ${DB_DATA_DIR}:/var/lib/mysql:rw
- logs:/var/log/mysql:ro
- ${LOG_DIR}/mysql:/var/log/mysql
- ${CONF_DIR}/mysql:/etc/mysql/conf.d
restart: unless-stopped
cap_add:
- SYS_NICE
- DAC_READ_SEARCH
environment:
MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD}
MYSQL_DATABASE: ${WORDPRESS_DB_NAME}
MYSQL_USER: ${WORDPRESS_DB_USER}
MYSQL_PASSWORD: ${WORDPRESS_DB_PASSWORD}
networks:
grf:
ipv4_address: 172.20.1.6
adminer:
image: adminer:${ADMINER_VER}
container_name: novalnet-adminer
hostname: novalnet-adminer
environment:
ADMINER_DEFAULT_SERVER: nmysql:3306
ADMINER_DESIGN: galkaev
env_file:
- .env
ports:
- "8082:8080"
links:
- nmysql
networks:
grf:
ipv4_address: 172.20.1.7
networks:
grf:
driver: bridge
ipam:
config:
- subnet: 172.20.1.0/24
volumes:
cdir: {}
logs: {}
- My host config file ./sites-available/novalnet.conf:
server {
server_name docker.novalnet.local;
server_tokens off;
server_name_in_redirect off;
listen *:80 default_server;
listen [::]:80 default_server reuseport;
access_log /var/log/nginx/access.log main_ext if=$no_logs;
#include /etc/nginx/bots.d/blockbots.conf;
#include /etc/nginx/bots.d/ddos.conf;
include /etc/nginx/header.d/httpd.conf;
return 301 https://$host$request_uri;
}
server {
server_name docker.novalnet.local;
server_tokens off;
server_name_in_redirect off;
root /usr/share/nginx/html;
listen *:443 default_server ssl http2;
listen [::]:443 default_server ssl http2 reuseport;
limit_req zone=req_zone burst=100 nodelay;
set $naxsi_flag_enable 0;
http2_push_preload on;
#access_log /var/log/nginx/access.log main_ext if=$no_logs;
error_log /var/log/nginx/error.log;
userid on;
userid_name _uid;
userid_path /;
userid_expires max;
userid_domain docker.novalnet.local;
#ssl on;
ssl_certificate /usr/share/nginx/html/ssl/xhost.crt;
ssl_certificate_key /usr/share/nginx/html/ssl/xhost.key;
#include /etc/nginx/conf.d/ssl.conf;
#include /etc/nginx/bots.d/blockbots.conf;
#include /etc/nginx/bots.d/ddos.conf;
include /etc/nginx/header.d/httpd.conf;
include /etc/nginx/header.d/proxy.conf;
#include /etc/nginx/conf.d/cdn.conf;
location / {
proxy_pass http://proxy/;
proxy_redirect / /;
error_page 502 =200 @failed;
}
include /etc/nginx/conf.d/secure.conf;
include /etc/nginx/conf.d/health.conf;
include /etc/nginx/conf.d/monit.conf;
include /etc/nginx/conf.d/purge.conf;
include /etc/nginx/conf.d/failed.conf;
}
server {
server_tokens off;
server_name_in_redirect off;
server_name docker.novalnet.local;
listen *:8080 default_server reuseport;
root /usr/share/nginx/html;
set $cache_uri $request_uri;
if ($redirect_uri) {return 301 $redirect_uri;}
#access_log /var/log/nginx/access.log main_ext if=$no_logs;
include /etc/nginx/conf.d/location.conf;
include /etc/nginx/redis.d/location.conf;
}
- My ./map.d/nocache/nocache.map :
~*\/wp-admin\/.* 1;
~*\/wp-content/plugins\/.* 1;
~*\/wp-[a-zA-Z0-9-]+\.php 1;
~*\/feed\/.* 1;
~*\/administrator\/.* 1;
~*\/sitemap(_index)?.xml 1;
~*\/xmlrpc.php 1;
~*\/wp-.*.php 1;
~*\/index.php 1;
~*\/cc.php 1;
~*\/purge\/.* 1;
~*\/kostenlose-payment-plugins\/.* 1;
~*\/kostenlose-payment-plugins 1;
HEAD 0;
GET 0;
I added uri
~*\/cc.php 1;
~*\/purge\/.* 1;
~*\/kostenlose-payment-plugins\/.* 1;
~*\/kostenlose-payment-plugins 1;
I changed nothing more
-
Cleared cache manually, deleting files in the folder /var/cache
-
Requested twice in a browser https://docker.novalnet.local/kostenlose-payment-plugins or https://docker.novalnet.local/cc.php In the browser console displayed
x-cache: HIT
All uri in the file ./map.d/nocache/nocache.map does not work. But the rules for cookies in the cookie.map file work. I can't understand what the problem is