Changed the config but still doesn’t work [Converter for Media
-
Can you tell me in detail how to modify these codes to my configuration? My server is Nginx
Follow the 4 steps below (please do all of them): Step 1 Find the configuration file in one of the paths (remember to select configuration file used by your vhost): – /etc/nginx/sites-available/ or /etc/nginx/sites-enabled/ – /etc/nginx/conf.d/ and add this code (add these lines at the beginning of the server { … } block) – remember to add these rules before any other location {} rules: BEGIN Converter for Media set $ext_avif ".avif"; if ($http_accept !~* "image/avif") { set $ext_avif ""; } set $ext_webp ".webp"; if ($http_accept !~* "image/webp") { set $ext_webp ""; } location ~ /wp-content/(?.+).(?jpe?g|png|gif|webp)$ { add_header Vary Accept; expires 365d; try_files /wp-content/uploads-webpc/$path.$ext$ext_avif /wp-content/uploads-webpc/$path.$ext$ext_webp $uri =404; } END Converter for Media Step 2 Then add support for the required MIME types, if they are not supported. Edit the configuration file: – /etc/nginx/mime.types and add this code (add these lines inside the types { … } block): image/webp webp; image/avif avif;
下面的是我的Nginx配置文件:
user www www; worker_processes auto; error_log /www/wwwlogs/nginx_error.log crit; pid /www/server/nginx/logs/nginx.pid; worker_rlimit_nofile 51200; stream { log_format tcp_format '$time_local|$remote_addr|$protocol|$status|$bytes_sent|$bytes_received|$session_time|$upstream_addr|$upstream_bytes_sent|$upstream_bytes_received|$upstream_connect_time'; access_log /www/wwwlogs/tcp-access.log tcp_format; error_log /www/wwwlogs/tcp-error.log; include /www/server/panel/vhost/nginx/tcp/*.conf; } events { use epoll; worker_connections 51200; multi_accept on; } http { include mime.types; #include luawaf.conf; include proxy.conf; default_type application/octet-stream; server_names_hash_bucket_size 512; client_header_buffer_size 32k; large_client_header_buffers 4 32k; client_max_body_size 50m; sendfile on; tcp_nopush on; keepalive_timeout 60; tcp_nodelay on; fastcgi_connect_timeout 300; fastcgi_send_timeout 300; fastcgi_read_timeout 300; fastcgi_buffer_size 64k; fastcgi_buffers 4 64k; fastcgi_busy_buffers_size 128k; fastcgi_temp_file_write_size 256k; fastcgi_intercept_errors on; gzip on; gzip_min_length 1k; gzip_buffers 4 16k; gzip_http_version 1.1; gzip_comp_level 2; gzip_types text/plain application/javascript application/x-javascript text/javascript text/css application/xml; gzip_vary on; gzip_proxied expired no-cache no-store private auth; gzip_disable "MSIE [1-6]\."; limit_conn_zone $binary_remote_addr zone=perip:10m; limit_conn_zone $server_name zone=perserver:10m; server_tokens off; access_log off; server { listen 888; server_name phpmyadmin; index index.html index.htm index.php; root /www/server/phpmyadmin; location ~ /tmp/ { return 403; } #error_page 404 /404.html; include enable-php.conf; # BEGIN Converter for Media set $ext_avif ".avif"; if ($http_accept !~* "image/avif") { set $ext_avif ""; } set $ext_webp ".webp"; if ($http_accept !~* "image/webp") { set $ext_webp ""; } location ~ /wp-content/(?<path>.+)\.(?<ext>jpe?g|png|gif|webp)$ { add_header Vary Accept; expires 365d; try_files /wp-content/uploads-webpc/$path.$ext$ext_avif /wp-content/uploads-webpc/$path.$ext$ext_webp $uri =404; } # END Converter for Media location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$ { expires 30d; } location ~ .*\.(js|css)?$ { expires 12h; } location ~ /\. { deny all; } access_log /www/wwwlogs/access.log; } include /www/server/panel/vhost/nginx/*.conf; }
我不会传图片,所以请见谅
Viewing 10 replies - 1 through 10 (of 10 total)
Viewing 10 replies - 1 through 10 (of 10 total)
- The topic ‘Changed the config but still doesn’t work [Converter for Media’ is closed to new replies.