Page 1 of 2
nginx: [emerg] "map" directive is not allowed here in /etc/nginx/nginx.conf:111
PostPosted:07 Nov 2018 10:07
by khoikhoi26
Em gặp lỗi này khi đang sử dụng.
---------------------------------------------------------
Rat tiec, VPSSIM khong the khoi dong lai duoc Nginx!
-------------------------------------------------------------------------
Nginx Status:
-------------------------------------------------------------------------
nginx: [emerg] "map" directive is not allowed here in /etc/nginx/nginx.conf:111
nginx: configuration file /etc/nginx/nginx.conf test failed
----------------------------------------------------------------------------
Note: Em không đụng chạm gì đến VPS khi cài xong cả mà vẫn bị. Cứ lâu lâu là bị 1 lần Nginx Stop (Em cài lại VPS mấy lần rồi) Nên giờ không cài nữa để nhờ các Bác giúp.
Thanks
Re: nginx: [emerg] "map" directive is not allowed here in /etc/nginx/nginx.conf:111
PostPosted:07 Nov 2018 10:12
by nguyenoanh
Em copy nội dung file
lên đây cho anh xem nhé.
Re: nginx: [emerg] "map" directive is not allowed here in /etc/nginx/nginx.conf:111
PostPosted:07 Nov 2018 10:13
by khoikhoi26
Code: Select alluser nginx;
worker_processes auto;
#worker_priority -10;
worker_rlimit_nofile 100000;
timer_resolution 100ms;
pcre_jit on;
error_log /var/log/nginx/error.log crit;
pid /var/run/nginx.pid;
include /etc/nginx/conf/dynamic-module-config.conf;
events {
worker_connections 3500;
use epoll;
#accept_mutex on;
#accept_mutex_delay 200ms;
multi_accept on;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
include /etc/nginx/conf/ddos1.conf;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
more_set_headers "Server: Nginx";
more_set_headers "X-Powered-By: VPSSIM"
access_log off;
sendfile on;
sendfile_max_chunk 512k;
tcp_nopush on;
tcp_nodelay on;
types_hash_max_size 2048;
server_tokens off;
server_name_in_redirect off;
server_names_hash_bucket_size 128;
open_file_cache max=130000 inactive=20s;
open_file_cache_valid 30s;
open_file_cache_min_uses 2;
open_file_cache_errors off;
open_log_file_cache max=10000 inactive=30s min_uses=2;
output_buffers 8 256k;
postpone_output 1460;
request_pool_size 32k;
connection_pool_size 512;
directio 4m;
client_body_buffer_size 256k;
client_body_timeout 60;
client_header_buffer_size 64k;
client_body_in_file_only off;
large_client_header_buffers 4 256k;
client_header_timeout 20;
ignore_invalid_headers on;
client_max_body_size 500m;
keepalive_timeout 25;
keepalive_requests 1000;
keepalive_disable msie6;
lingering_time 20s;
lingering_timeout 5s;
reset_timedout_connection on;
send_timeout 50;
gzip on;
gzip_static on;
gzip_disable "msie6";
gzip_vary on;
gzip_proxied any;
gzip_comp_level 5;
gzip_buffers 32 8k;
gzip_min_length 1024;
gzip_http_version 1.1;
gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
# Cloudflare module cho nginx
set_real_ip_from 204.93.240.0/24;
set_real_ip_from 204.93.177.0/24;
set_real_ip_from 199.27.128.0/21;
set_real_ip_from 173.245.48.0/20;
set_real_ip_from 103.21.244.0/22;
set_real_ip_from 103.22.200.0/22;
set_real_ip_from 103.31.4.0/22;
set_real_ip_from 141.101.64.0/18;
set_real_ip_from 108.162.192.0/18;
set_real_ip_from 190.93.240.0/20;
set_real_ip_from 188.114.96.0/20;
set_real_ip_from 197.234.240.0/22;
set_real_ip_from 198.41.128.0/17;
set_real_ip_from 162.158.0.0/15;
set_real_ip_from 104.16.0.0/12;
set_real_ip_from 2400:cb00::/32;
set_real_ip_from 2606:4700::/32;
set_real_ip_from 2803:f800::/32;
set_real_ip_from 2405:b500::/32;
set_real_ip_from 2405:8100::/32;
real_ip_header CF-Connecting-IP;
include /etc/nginx/conf.d/*.conf;
}
# http config block
map $http_accept $webp_ext {
default "";
"~*webp" ".webp";
}
# server config block
location ~* ^/wp-content/.+\.(png|jpg)$ {
add_header Vary Accept;
try_files $uri$webp_ext $uri =404;
}
Re: nginx: [emerg] "map" directive is not allowed here in /etc/nginx/nginx.conf:111
PostPosted:07 Nov 2018 10:16
by nguyenoanh
Thế này mà em bảo em không động gì đến config hả ?
Em xóa config em thêm vào nó nhé:
Code: Select all# http config block
map $http_accept $webp_ext {
default "";
"~*webp" ".webp";
}
Config này gây lỗi chứ đâu
Re: nginx: [emerg] "map" directive is not allowed here in /etc/nginx/nginx.conf:111
PostPosted:07 Nov 2018 10:20
by khoikhoi26
Sao em xoá luôn cài dòng
# http config block
map $http_accept $webp_ext {
default "";
"~*webp" ".webp";
}
Mà giờ vẫn lỗi anh nhỉ
Re: nginx: [emerg] "map" directive is not allowed here in /etc/nginx/nginx.conf:111
PostPosted:07 Nov 2018 10:21
by khoikhoi26
Cái này là em cài cái định dạng .webp cho hình ảnh trên wordpress mà không thành công. E xoá luôn cái plugin đó lâu rồi mà ta.
Re: nginx: [emerg] "map" directive is not allowed here in /etc/nginx/nginx.conf:111
PostPosted:07 Nov 2018 10:23
by khoikhoi26
Code: Select all# http config block
map $http_accept $webp_ext {
default "";
"~*webp" ".webp";
}
# server config block
location ~* ^/wp-content/.+\.(png|jpg)$ {
add_header Vary Accept;
try_files $uri$webp_ext $uri =404;
}
Em xoá cả 2 dòng này là lại được rồi. Thanks anh
Re: nginx: [emerg] "map" directive is not allowed here in /etc/nginx/nginx.conf:111
PostPosted:07 Nov 2018 10:23
by nguyenoanh
khoikhoi26 wrote: ↑07 Nov 2018 10:20
Sao em xoá luôn cài dòng
# http config block
map $http_accept $webp_ext {
default "";
"~*webp" ".webp";
}
Mà giờ vẫn lỗi anh nhỉ
Lỗi như thế nào thì em post lên cho anh luôn.
Mà tiện thể xóa luôn config dưới đi.
Để an toàn, mỗi khi em thêm config mới vào các file vhost hay các file cấu hình nginx, em phải test xem có được không ?
nếu lỗi thì xóa nó đi và làm lại.
Anh chắc chắn em có động đến config nginx, bây giờ cứ chạy lệnh nginx -t để tìm lỗi và fix nó.
Re: nginx: [emerg] "map" directive is not allowed here in /etc/nginx/nginx.conf:111
PostPosted:07 Nov 2018 10:24
by nguyenoanh
khoikhoi26 wrote: ↑07 Nov 2018 10:23
Code: Select all# http config block
map $http_accept $webp_ext {
default "";
"~*webp" ".webp";
}
# server config block
location ~* ^/wp-content/.+\.(png|jpg)$ {
add_header Vary Accept;
try_files $uri$webp_ext $uri =404;
}
Em xoá cả 2 dòng này là lại được rồi. Thanks anh
OKie em
Re: nginx: [emerg] "map" directive is not allowed here in /etc/nginx/nginx.conf:111
PostPosted:07 Nov 2018 10:28
by khoikhoi26
Em cảm ơn anh ạ.