• We value your experience with Plesk during 2024
    Plesk strives to perform even better in 2025. To help us improve further, please answer a few questions about your experience with Plesk Obsidian 2024.
    Please take this short survey:

    https://pt-research.typeform.com/to/AmZvSXkx
  • The Horde webmail has been deprecated. Its complete removal is scheduled for April 2025. For details and recommended actions, see the Feature and Deprecation Plan.
  • We’re working on enhancing the Monitoring feature in Plesk, and we could really use your expertise! If you’re open to sharing your experiences with server and website monitoring or providing feedback, we’d love to have a one-hour online meeting with you.

Issue Host settings and htaccess behavior in nginx proxy mode

Teal_cfr

Basic Pleskian
Server operating system version
Ubuntu 20.04 TS
Plesk version and microupdate number
Obsidian 18.0.52
Hi Everyone,

I'm facing a problem since few days, that i don't understand why.
Thys case is on one dedicated server with ubuntu 20.04 LTS with Obsidian 18.0.52
128G of RAM and Intel(R) Xeon(R) CPU E5-1660 v4 @ 3.20GHz (16 core(s))

The first point is I'm working on my TTFB which have an average of 3sec :|

I have "only" 6 hosts on this server.
Globally the server doesn't look to be overloaded.

1685080414870.png

But my Apache looks to be under pressure

1685080471425.png

So trying to handle this point I switched all my host on php 8.2.x

Then for the focused domain that i'm working on i used FPM Application served by nginx.
To be sure that my htaccess still working I switched on the proxy mode

I didn't fully switch to nginx since i'm not used to transfer rules from Apache to nginx.
So I used this setting.

1685080688277.png

Ok from this point the problem is :

I have redirection rules in my htaccess.....and when I try them it works !

But... I have other rules on this htaccess and they don't works.

I try to test my htaccess with a third part app and it works fine
So now I have no clues why all my rules are not used.

typically

# BEGIN Imagify: rewrite rules for webp <IfModule mod_setenvif.c> # Vary: Accept for all the requests to jpeg, png, and gif. SetEnvIf Request_URI "\.(jpg|jpeg|jpe|png|gif|webp)$" REQUEST_image </IfModule> <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / # Check if browser supports WebP images. RewriteCond %{HTTP_ACCEPT} image/webp # Check if WebP replacement image exists. RewriteCond %{REQUEST_FILENAME}.webp -f # Serve WebP image instead. RewriteRule (.+)\.(jpg|jpeg|jpe|png|gif|webp)$ $1.$2.webp [T=image/webp,NC] </IfModule> <IfModule mod_headers.c> Header append Vary Accept env=REQUEST_image </IfModule> # END Imagify: rewrite rules for webp # BEGIN Imagify: webp file type <IfModule mod_mime.c> AddType image/webp .webp </IfModule> # END Imagify: webp file type

And result in web browser
1685081573092.png

An other example is :

<IfModule mod_alias.c> <FilesMatch "\.(html|htm|rtf|rtx|txt|xsd|xsl|xml)$"> <IfModule mod_headers.c> Header set X-Powered-By "WP Rocket/3.13.2" Header unset Pragma Header append Cache-Control "public" Header unset Last-Modified </IfModule> </FilesMatch>

And result in web browser :
1685081659116.png


The cache mod is activated on my Apache
1685081776867.png

Then I had to add this rule to make the header expires cache information working.

1685081840218.png

But I want my customs rules working on my htaccess

<FilesMatch "\.(css|htc|js|asf|asx|wax|wmv|wmx|avi|bmp|class|divx|doc|docx|eot|exe|gif|gz|gzip|ico|jpg|jpeg|jpe|json|mdb|mid|midi|mov|qt|mp3|m4a|mp4|m4v|mpeg|mpg|mpe|mpp|otf|odb|odc|odf|odg|odp|ods|odt|ogg|pdf|png|pot|pps|ppt|pptx|ra|ram|svg|svgz|swf|tar|tif|tiff|ttf|ttc|wav|wma|wri|xla|xls|xlsx|xlt|xlw|zip)$"> <IfModule mod_headers.c> Header unset Pragma Header append Cache-Control "public" </IfModule> </FilesMatch> </IfModule> <IfModule mod_mime.c> AddType image/avif avif AddType image/avif-sequence avifs </IfModule> # Expires headers (for better cache control) <IfModule mod_expires.c> ExpiresActive on ExpiresDefault "access plus 1 month" # cache.appcache needs re-requests in FF 3.6 (thanks Remy ~Introducing HTML5) ExpiresByType text/cache-manifest "access plus 0 seconds" # Your document html ExpiresByType text/html "access plus 0 seconds" # Data ExpiresByType text/xml "access plus 0 seconds" ExpiresByType application/xml "access plus 0 seconds" ExpiresByType application/json "access plus 0 seconds" # Feed ExpiresByType application/rss+xml "access plus 1 hour" ExpiresByType application/atom+xml "access plus 1 hour" # Favicon (cannot be renamed) ExpiresByType image/x-icon "access plus 1 week" # Media: images, video, audio ExpiresByType image/jpg "access plus 4 months" ExpiresByType image/gif "access plus 4 months" ExpiresByType image/png "access plus 4 months" ExpiresByType image/jpeg "access plus 4 months" ExpiresByType image/webp "access plus 4 months" ExpiresByType video/ogg "access plus 4 months" ExpiresByType audio/ogg "access plus 4 months" ExpiresByType video/mp4 "access plus 4 months" ExpiresByType video/webm "access plus 4 months" ExpiresByType image/avif "access plus 4 months" ExpiresByType image/avif-sequence "access plus 4 months" # HTC files (css3pie) ExpiresByType text/x-component "access plus 1 month" # Webfonts ExpiresByType font/ttf "access plus 4 months" ExpiresByType font/otf "access plus 4 months" ExpiresByType font/woff "access plus 4 months" ExpiresByType font/woff2 "access plus 4 months" ExpiresByType image/svg+xml "access plus 4 months" ExpiresByType application/vnd.ms-fontobject "access plus 1 month" # CSS and JavaScript ExpiresByType text/css "access plus 1 year" ExpiresByType application/javascript "access plus 1 year" </IfModule>


I tried this without any effects :

1685081980288.png


And also tried this in Additional nginx directives, and no results as well

location ~* \.(js|jpg|jpeg|gif|png|css|tgz|gz|rar|bz2|doc|pdf|ppt|tar|wav|bmp|rtf|swf|ico|flv|txt|woff|woff2|svg)$ { expires 30d; add_header Pragma "public"; add_header Cache-Control "public"; } # BEGIN Imagify: rewrite rules for webp location ~* ^(/.+)\.(jpg|jpeg|jpe|png|gif|webp)$ { add_header Vary Accept; if ($http_accept ~* "webp"){ set $imwebp A; } if (-f $request_filename.webp) { set $imwebp "${imwebp}B"; } if ($imwebp = AB) { rewrite ^(.*) $1.webp; } } # END Imagify: rewrite rules for webp
 
You should not at the same time use proxy mode, but choose PHP via Nginx, because proxy mode forwards all .php requests to Apache.
 
Back
Top