Apache is not serving some content from a mounted network share for me on Ubuntu.
Depending on the content of the file I try to open it is not correctly served:
This does not work:
is a link to another nifty site
<H2>This is a Medium Header</H2>
Chrome issues the following error message: "ERR_INVALID_HTTP_RESPONSE"
Postman: "Error: Parse Error: Expected HTTP/"
curl: "curl: (1) Received HTTP/0.9 when not allowed"
This works (just one more blank line)
is a link to another nifty site
<H2>This is a Medium Header</H2>
The network share is mounted in /media/data (cifs; for testing purposes permissions are set to 777)
There's a symbolic link from /var/www/server to /media/data and i can see and change the contents from inside the VM.
It does not make to much sense to me that apache is picky about the file contents. I'm not entirely sure how to interpret the error messages from the 3 different clients, but since all of them are failing it looks like Apache is the issue even though the error log does not show any problems.
After copying the file to /var/www/html (default directory) and changing the vhost to that location the files get served no matter what the content is.
I don't know if this does matter at all but while searching "ERR_INVALID_HTTP_RESPONSE" online I found some people talking about chrome behaving weirdly on some ports: I'm currently running the server on Port 28080 (for backwards compatibility with the current setup and because I'm planning on setting up nginx on port 80); nginx is already installed but I don't think it's interfering.
Please excuse me if this sounds somewhat confusing but that's propably just because I'm utterly confused myself.
This is a clean VM, the only additional packages are apache, nginx and cifs-utils as far as I know.
Has anyone else encountered weird behaviour with network shares in this context? I want the htdocs on the network share since it is easier for me to access from my windows machine, are there any recommended ways of accessing the htdocs other than a network share?
Edit:
curl --verbose --output out.txt --http0.9 localhost:28080/test.html
gives the following console output:
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0* Trying 127.0.0.1:28080...
* TCP_NODELAY set
* Connected to localhost (127.0.0.1) port 28080 (#0)
> GET /test.html HTTP/1.1
> Host: localhost:28080
> User-Agent: curl/7.68.0
> Accept: */*
>
{ [15 bytes data]
100 294 0 294 0 0 58 0 --:--:-- 0:00:05 --:--:-- 0
* Closing connection 0
While out.txt contains the following:
18:55:12 GMT
ETag: *removed*
Accept-Ranges: bytes
Content-Length: 67
Content-Type: text/html
is a link to another nifty site
<H2>This is a Medium Header</H2>
^@^@^@^@^@^@�)^@^@^@^@^@^@w�^@^@�r�X]﹟^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^X^@^@^@^@^@^@^@����������������^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@
On another file the weird string at the end actually contains the keyword SMB. I don't know if this is a coincidence or if this actually means something:
19:34:11 GMT
ETag: *removed*
Accept-Ranges: bytes
Content-Length: 6
Content-Type: text/plain
sadssa^@^@^@^@]﹟^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@)^@^A^Re ^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@�����������������SMB@^@^@^@^@^@^@^@^F^@
^@^D^@^@^@^@^@^@^@�)^@^@^@^@^@^@w�^@^@�r�X]﹟^@^@^@^@^@
I also noticed the r and X part which could have something to do with the file permissions?
Edit 2:
network share (fstab):
//www.example.com/Share /media/data cifs username=user,password=pass,domain=WORKGROUP,vers=2.0,file_mode=0777,dir_mode=0777 0 0
symlink established with:
sudo ln -s /media/data/ /var/www/server
apache2.conf:
[...]
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
[...]
--http0.9
flag? Try also--http2-prior-knowledge
.http2 error: Remote peer returned unexpected data while we expected SETTINGS frame. Perhaps, peer does not support HTTP/2 properly.
Options +FollowSymLinks
inhttpd.conf
?www-data
problem. Have fun.