• Please be aware: Kaspersky Anti-Virus has been deprecated
    With the upgrade to Plesk Obsidian 18.0.64, "Kaspersky Anti-Virus for Servers" will be automatically removed from the servers it is installed on. We recommend that you migrate to Sophos Anti-Virus for Servers.
  • 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.

Issue htaccess header missing

SKDamon

Basic Pleskian
Server operating system version
Ubuntu 22.04.4
Plesk version and microupdate number
18.0.63.3
I've recently migrated a domain from an old Plesk Host to a newer one, the old Plesk did not use nginx at all.
After migration to the new host, I noticed breakage on the site because headers that were supposed to be set server-side via .htaccess were not present anymore.

.htaccess sets the header:
Apache config:
<FilesMatch "\.(jpeg|jpg|png|svg|pdf|mp4|gif)$">
    Header add Access-Control-Allow-Origin "*"
    Header add Access-Control-Allow-Methods: "GET"
</FilesMatch>

I did not touch any hosting settings for the domain after migration, it was still set to:
PHP Handler: 8.3.0, Dedicated FPM application (Apache)
Hosting -> Apache & Nginx -> Proxy mode [enabled]
(everything else on this settings page is not enabled, except for additional HTTP/S directives that the Plesk Migration wizard copied over)

From my understanding, this should result in Apache being used to process the request (after being proxied through nginx), hence .htaccess should continue to work?
But apparently, the Access-Control-Allow-Origin/Methods headers were missing on URIs which previously had them...

Why are the headers missing? Is the nginx proxy stripping those from the response?

BTW I fixed it through additional nginx directives, but I need to know why the .htaccess directives are not working anymore, and how to re-enable them so I can migrate all other domains from the old Plesk host without further mishaps.
Thanks guys.
 
It's a bug in the migrator extension or Plesk UI, depends on what happens internally...

I've tested with a new domain on the old server, just an .htaccess to set headers (X-Custom-Test: * on all requests, X-File-Matched: true inside FilesMatch .png directive), and a dummy PNG.

Before migration (on old server):
Bash:
user@localhost$ curl -v -s http://headers.test/test.png 1>/dev/null
[...]
< X-Custom-Test: *
< X-File-Matched: true
{ [4032 bytes data]

After migration to new server (no settings touched),
note that X-Custom-Test and X-File-Matched are missing:
Bash:
user@localhost$ curl -v -s http://headers.test/test.png 1>/dev/null
*   Trying W.X.Y.Z:80...
* TCP_NODELAY set
* Connected to headers.test (W.X.Y.Z) port 80 (#0)
> GET /test.png HTTP/1.1
> Host: headers.test
> User-Agent: curl/7.68.0
> Accept: */*
>
* Mark bundle as not supporting multiuse
< HTTP/1.1 200 OK
< Server: nginx
< Date: Fri, 30 Aug 2024 07:25:18 GMT
< Content-Type: image/png
< Content-Length: 40633
< Last-Modified: Fri, 30 Aug 2024 07:16:07 GMT
< Connection: keep-alive
< ETag: "66d171b7-9eb9"
< X-Powered-By: PleskLin
< Accept-Ranges: bytes
<
{ [1440 bytes data]
* Connection #0 to host headers.test left intact

After manually turning on Apache&Nginx -> Smart static files processing",
headers are still missing but nginx now directly handles the request w/o apache,
as indicated by the bigger chunk of data (2nd to last line):
Bash:
user@localhost$ curl -v -s http://headers.test/test.png 1>/dev/null
*   Trying W.X.Y.Z:80...
* TCP_NODELAY set
* Connected to headers.test (W.X.Y.Z) port 80 (#0)
> GET /test.png HTTP/1.1
> Host: headers.test
> User-Agent: curl/7.68.0
> Accept: */*
>
* Mark bundle as not supporting multiuse
< HTTP/1.1 200 OK
< Server: nginx
< Date: Fri, 30 Aug 2024 07:27:34 GMT
< Content-Type: image/png
< Content-Length: 40633
< Last-Modified: Fri, 30 Aug 2024 07:16:07 GMT
< Connection: keep-alive
< ETag: "66d171b7-9eb9"
< X-Powered-By: PleskLin
< Accept-Ranges: bytes
<
{ [5760 bytes data]
* Connection #0 to host headers.test left intact

Turned off "Smart static files processing" again, the Headers are now correctly set:
Bash:
user@localhost$ curl -v -s http://headers.test/test.png 1>/dev/null
*   Trying W.X.Y.Z:80...
* TCP_NODELAY set
* Connected to headers.test (W.X.Y.Z) port 80 (#0)
> GET /test.png HTTP/1.1
> Host: headers.test
> User-Agent: curl/7.68.0
> Accept: */*
>
* Mark bundle as not supporting multiuse
< HTTP/1.1 200 OK
< Server: nginx
< Date: Fri, 30 Aug 2024 07:28:06 GMT
< Content-Type: image/png
< Content-Length: 40633
< Connection: keep-alive
< Last-Modified: Fri, 30 Aug 2024 07:16:07 GMT
< ETag: "9eb9-620e15d669bc0"
< Accept-Ranges: bytes
< X-Custom-Test: *
< X-File-Matched: true
< X-Powered-By: PleskLin
<
{ [1105 bytes data]
* Connection #0 to host headers.test left intact

Actual case of "turn it on and off again" fixing stuff... :)

Where can I file the bug?
 
Back
Top