[RESOLVED] webserver refuses to serve contents of a symbolic link

Post your questions about Web Server usage and Apache + PHP + MySQL/SQLite web applications.
FSC830
Experience counts
Posts: 2043
Joined: Thu Mar 03, 2016 1:11 am

Re: webserver refuses to serve contents of a symbolic link

Post by FSC830 »

Not sure, what you really want to achieve, but running with virtual hosts is easy and I guess this is what you need to do.

Attached are some screenshots from my test environment in which I played around with vhosts some months ago. Important thing is that your client needs to be able of a name resolution
The vhosts needs to be adressed using a FQDN, only a hostname fails.
So you need to enter the FQDN in a local DNS or in hosts file of client pc.

Q902-3 is the name of the NAS, using default port to access administrative page. See the virtual host settings for details about the protocol and port used for each vhost.

Regards
Web_01.png
Web_02.png
Web_03.png
Web_04.png
You do not have the required permissions to view the files attached to this post.
Last edited by FSC830 on Thu Apr 07, 2022 6:56 am, edited 3 times in total.
dutsnekcirf
Getting the hang of things
Posts: 54
Joined: Fri Apr 08, 2011 9:52 am

Re: webserver refuses to serve contents of a symbolic link

Post by dutsnekcirf »

FSC830,

Thank you for your response and for the screenshots you provided. I enabled vhosts on the NAS and created a new entry for repo.mts.sys pointing to /Web/repo on port 80. I used your screenshot as an example. I also ensured that my dns server has an entry for "repo and repo.mts.sys" pointing to the IP address of my NAS. Unfortunately, I'm still getting the same results.

See attached.
vhosts.PNG
error2.PNG
You do not have the required permissions to view the files attached to this post.
dosborne
Experience counts
Posts: 1824
Joined: Tue May 29, 2018 3:02 am
Location: Ottawa, Ontario, Canada

Re: webserver refuses to serve contents of a symbolic link

Post by dosborne »

My symbolic link was not at the root level. Maybe that's why it worked for me.
QNAP TS-563-16G 5x10TB Seagate Ironwolf HDD Raid-5 NIC: 2x1GB 1x10GbE
QNAP TS-231P-US 2x18TB Seagate Exos HDD Raid-1
[Deadbolt and General Ransomware Detection, Prevention, Recovery & MORE]
FSC830
Experience counts
Posts: 2043
Joined: Thu Mar 03, 2016 1:11 am

Re: webserver refuses to serve contents of a symbolic link

Post by FSC830 »

Hi,

sorry, no idea, what you did. But using symlinks is not a problem at all. May be a permission issue?
See my configuration:
Sreenshot shows file index.html in directory /share/repo and its contents and the symbolic link in .../Web/repo (username is masked, symlink was not created with "admin")
repo_01.png
The vHost settings
repo_02.png
And here the result calling this host without and with the addtional "/repo"
repo_03.png
repo_03a.png
Regards

Edit: BTW, my previous screenshot was with QTS 4.3.4, there you can see multiple hosts with port 80. In QTS 5.0 it seems, that a port can only be used once. No idea, if this is a bug or a feature, but creating a new vhost and set an already existent ports ends in a message "port is already used for service".
A NAS with QTS 5.0.0.1986 was used for the screenshots above.
You do not have the required permissions to view the files attached to this post.
Last edited by FSC830 on Thu Apr 07, 2022 8:08 pm, edited 2 times in total.
FSC830
Experience counts
Posts: 2043
Joined: Thu Mar 03, 2016 1:11 am

Re: webserver refuses to serve contents of a symbolic link

Post by FSC830 »

Got it!

Name your symlink index.html, then calling the host is possible without adding /repo to the URL:
(this time I used admin account for the symlink)
repo_04.png
repo_04a.png
Regards
You do not have the required permissions to view the files attached to this post.
dutsnekcirf
Getting the hang of things
Posts: 54
Joined: Fri Apr 08, 2011 9:52 am

Re: webserver refuses to serve contents of a symbolic link

Post by dutsnekcirf »

FSC830!

We are getting really close. I did the same thing that you did with an index.html file under the repo directory. It serves the index.html file just fine. It looks just like yours! This led me to see if it'll serve any files underneath my /share/repo directory structure and it does! As long as I specify the full path to the file itself to serve. So I think my real problem is actually that it doesn't list the directory structure, or allow me to browse the directory structure.

I'm used to seeing something like the following when I simply browse to a directory being served by the webserver:
directory listing.PNG
Be aware that this attached screenshot is an example from a different webserver in my environment. Not a QNAP of any kind.

Is there an httpd setting that prevents browsing of the directory structure?
You do not have the required permissions to view the files attached to this post.
User avatar
dolbyman
Guru
Posts: 35272
Joined: Sat Feb 12, 2011 2:11 am
Location: Vancouver BC , Canada

Re: webserver refuses to serve contents of a symbolic link

Post by dolbyman »

FSC830
Experience counts
Posts: 2043
Joined: Thu Mar 03, 2016 1:11 am

Re: webserver refuses to serve contents of a symbolic link

Post by FSC830 »

:'
Never used directory listing via http/https. But it can be realized also by modifying the apache.conf: https://cwiki.apache.org/confluence/dis ... ryListings or
https://www.ibm.com/support/pages/setti ... g-web-page.
Settings in .htaccess file needs to checked as well as @dolbyman wrote.
But IMHO: this is a very unsual request and I would never allow anybody the show up the directory listing of a web server.

What is the purpose to show directory content?

Regards
dosborne
Experience counts
Posts: 1824
Joined: Tue May 29, 2018 3:02 am
Location: Ottawa, Ontario, Canada

Re: webserver refuses to serve contents of a symbolic link

Post by dosborne »

FSC830 wrote: Tue Apr 12, 2022 2:47 pm What is the purpose to show directory content?
I use it all the time for personal access to files. I have quite a bit of data laid out across folders and well organized so it makes it easy to find and no "work" is required creating html files etc.
I also use it for accessing my video files from my mobile device.

There really are valid use cases for it. Not for everyone or all situations, but it is very handy in some specific instances.
QNAP TS-563-16G 5x10TB Seagate Ironwolf HDD Raid-5 NIC: 2x1GB 1x10GbE
QNAP TS-231P-US 2x18TB Seagate Exos HDD Raid-1
[Deadbolt and General Ransomware Detection, Prevention, Recovery & MORE]
dutsnekcirf
Getting the hang of things
Posts: 54
Joined: Fri Apr 08, 2011 9:52 am

[RESOLVED] Re: webserver refuses to serve contents of a symbolic link

Post by dutsnekcirf »

I'm marking this resolved.

So if I'm completely honest with myself and consider my final objective, well, it's so that I can use the QNAP as a means to host offline copies of various Linux repositories. Being able to browse the directory structure from a web browser is not entirely necessary to achieve that goal. Drawing from (limited) past experience with basic Apache web servers, being able to browse the directory structure was a default behavior. It was how I could confirm that my repos were indeed accessible. I often use the curl command from client machines to confirm that the files are indeed accessible to the system's package manager; such as yum or dnf.

Now that I've switched to using a QNAP to host my repos, the behavior was just...different. I understand now that QNAP prevents browsing the directory structure by default as a security measure. The fact that I was using a symbolic link was a red herring.

I enabled browsing of the directory structure by adding a .htaccess file to the /share/Web directory. I added the following line without the quotes to the file: "Options +Indexes"

The links that were posted by FSC830 and dosborne were very useful.

At this point everything is working the way I'm used to. Thanks again for the help and support!
Post Reply

Return to “Web Server & Applications (Apache + PHP + MySQL / SQLite)”