PDA

View Full Version : "default.html" file on web server




Jaggions
Aug 20, 2013, 12:22 PM
Hi. I have just started a server using OS X Server 10.8. I have already set up AFP and SSH sharing and now I'd like to configure HTTP sharing too, so that surfing to 192.168.1.XXX I can access and download my files. What I did probably worked, because surfing to 192.168.1.XXX I can see this page:

http://i40.tinypic.com/rvhpw9.png

I browsed to the indicated path and removed the sample content of the "Default" directory, and now I'd need to edit the "default.html" file. I'd like to edit it so that surfing to 192.168.1.XXX I get an index page like this:

http://i39.tinypic.com/275e1.png

...but how? I don't know much about html and servers, can you help me please? Thank you.



MacUser2525
Aug 20, 2013, 01:51 PM
Move or delete the default.html file and Apache should automatically default to a directory listing like you want.

Edit: Most times the default.html as you have here is the index.html file who knows perhaps Apple has named it default.html but I doubt it.

Jaggions
Aug 20, 2013, 02:03 PM
Move or delete the default.html file and Apache should automatically default to a directory listing like you want.


I deleted the file and restarted Apache, but surfing to 192.168.1.XXX now gives me the "403 Forbidden" error (You don't have the permission to access / on this server). Removing the whole "Default" folder, instead, results in a 404 error.


Edit: Most times the default.html as you have here is the index.html file who knows perhaps Apple has named it default.html but I doubt it.

Yeah, in my opinion here "default.html" is "index.html". Does this make any difference?

MacUser2525
Aug 20, 2013, 02:14 PM
I deleted the file and restarted Apache, but surfing to 192.168.1.XXX now gives me the "403 Forbidden" error (You don't have the permission to access / on this server). Removing the whole "Default" folder, instead, results in a 404 error.


Lovely a permission error I did not get when I moved the file on my linux server. You can try creating a new directory under the existing one and giving it world readable permissions a rwxrwxrwx or 0777 if using chmod to do it, it may not be necessary to do the world readable off the start try it without if it does not work then make it so. Then you would navigate to http://192.168.1.XXX/new_directory_name/ to access your files.


Yeah, in my opinion here "default.html" is "index.html". Does this make any difference?

Don't matter what it is named if that file is present then you will get the html read and displayed instead of the directory listing you want.

Jaggions
Aug 20, 2013, 02:21 PM
Lovely a permission error I did not get when I moved the file on my linux server. You can try creating a new directory under the existing one and giving it world readable permissions a rwxrwxrwx or 0777 if using chmod to do it, it may not be necessary to do the world readable off the start try it without if it does not work then make it so. Then you would navigate to http://192.168.1.XXX/new_directory_name/ to access your files.

Still no luck :(

MacUser2525
Aug 20, 2013, 02:30 PM
Still no luck :(


As in it will still not allow you to access a newly created world readable/writeable directory contained under the Default directory, if so I have no clue where to go from here Apple has one whacked implementation of Apache.

ElectricSheep
Aug 20, 2013, 02:34 PM
Out of the box, Mac OS X Server's (10.8+) comes with quite a bit of configuration. The base configuration file should be located at /Library/Server/Web/Config/apache2/httpd_server_app.conf. This sets up the core apache configuration, but it also contain includes to other .conf files which provide further options. For your purposes, you are going to be interested in the configuration files located in /Library/Server/Web/Config/apache2/sites/. There should be a file called 0000_any_80_.conf. This contain the VirtualHost configuration for *:80, which means any listening interface port 80.

If you look inside this file, you should see something like:


<VirtualHost *:80>
ServerAdmin admin@example.com
DocumentRoot "/Library/Server/Web/Data/Sites/Default"
DirectoryIndex index.html index.php default.html
CustomLog "/var/log/apache2/access_log" combinedvhost
ErrorLog "/var/log/apache2/error_log"
<IfModule mod_ssl.c>
SSLEngine Off
SSLCipherSuite "ALL:!aNULL:!ADH:!eNULL:!LOW:!EXP:RC4+RSA:+HIGH:+MEDIUM"
SSLProtocol -ALL +SSLv3 +TLSv1
SSLProxyEngine On
SSLProxyProtocol -ALL +SSLv3 +TLSv1
</IfModule>
<Directory "/Library/Server/Web/Data/Sites/Default">
Options All -Indexes -ExecCGI -Includes +MultiViews
AllowOverride None
<IfModule mod_dav.c>
DAV Off
</IfModule>
<IfDefine !WEBSERVICE_ON>
Deny from all
ErrorDocument 403 /customerror/websitesoff403.html
</IfDefine>
</Directory>
ProxyPass /__collabd/streams/activity balancer://balancer-group-webapp-com.apple.webapp.collabd--__collabd-streams-activity
...
</VirtualHost>


You can see that the document root is /Library/Server/Web/Data/Sites/Default, and that directory has some options set for it. One of those options is -Indexes which disables the generation of auto-indexes when a suitable index specified by DirectoryIndex cannot be found. If you remove -Indexes and restart apache, you should find that the document root will return a directory listing when you access your web server. You could also change the document root to point somewhere else; I strongly advise against pointing it at someplace like "/" or "/Users/".

MacUser2525
Aug 20, 2013, 02:48 PM
Out of the box, Mac OS X Server's (10.8+) comes with quite a bit of configuration. The base configuration file should be located at /Library/Server/Web/Config/apache2/httpd_server_app.conf. This sets up the core apache configuration, but it also contain includes to other .conf files which provide further options. For your purposes, you are going to be interested in the configuration files located in /Library/Server/Web/Config/apache2/sites/. There should be a file called 0000_any_80_.conf. This contain the VirtualHost configuration for *:80, which means any listening interface port 80.

If you look inside this file, you should see something like:


<VirtualHost *:80>
ServerAdmin admin@example.com
DocumentRoot "/Library/Server/Web/Data/Sites/Default"
DirectoryIndex index.html index.php default.html
CustomLog "/var/log/apache2/access_log" combinedvhost
ErrorLog "/var/log/apache2/error_log"
<IfModule mod_ssl.c>
SSLEngine Off
SSLCipherSuite "ALL:!aNULL:!ADH:!eNULL:!LOW:!EXP:RC4+RSA:+HIGH:+MEDIUM"
SSLProtocol -ALL +SSLv3 +TLSv1
SSLProxyEngine On
SSLProxyProtocol -ALL +SSLv3 +TLSv1
</IfModule>
<Directory "/Library/Server/Web/Data/Sites/Default">
Options All -Indexes -ExecCGI -Includes +MultiViews
AllowOverride None
<IfModule mod_dav.c>
DAV Off
</IfModule>
<IfDefine !WEBSERVICE_ON>
Deny from all
ErrorDocument 403 /customerror/websitesoff403.html
</IfDefine>
</Directory>
ProxyPass /__collabd/streams/activity balancer://balancer-group-webapp-com.apple.webapp.collabd--__collabd-streams-activity
...
</VirtualHost>


You can see that the document root is /Library/Server/Web/Data/Sites/Default, and that directory has some options set for it. One of those options is -Indexes which disables the generation of auto-indexes when a suitable index specified by DirectoryIndex cannot be found. If you remove -Indexes and restart apache, you should find that the document root will return a directory listing when you access your web server. You could also change the document root to point somewhere else; I strongly advise against pointing it at someplace like "/" or "/Users/".


Interesting but does not apply to a normal OSXs install I just turned on the web server here then moved the file and it works like it should ie. gives me an index of the directory when I enter the IP address of my machine in browser.


sudo mv /Library/WebServer/Documents/index.html.en /Library/WebServer/Documents/index.html.en.orig

ElectricSheep
Aug 20, 2013, 03:02 PM
Interesting but does not apply to a normal OSXs install I just turned on the web server here then moved the file and it works like it should ie. gives me an index of the directory when I enter the IP address of my machine in browser.


sudo mv /Library/WebServer/Documents/index.html.en /Library/WebServer/Documents/index.html.en.orig


But, as the OP pointed out, this is OS X Server 10.8. The configuration is completely different that what used to ship out of the box as "Personal Websharing" with MacOS X 10.7 and below.

Jaggions
Aug 20, 2013, 04:47 PM
Out of the box, Mac OS X Server's (10.8+) comes with quite a bit of configuration. The base configuration file should be located at /Library/Server/Web/Config/apache2/httpd_server_app.conf. This sets up the core apache configuration, but it also contain includes to other .conf files which provide further options. For your purposes, you are going to be interested in the configuration files located in /Library/Server/Web/Config/apache2/sites/. There should be a file called 0000_any_80_.conf. This contain the VirtualHost configuration for *:80, which means any listening interface port 80.

If you look inside this file, you should see something like:


<VirtualHost *:80>
ServerAdmin admin@example.com
DocumentRoot "/Library/Server/Web/Data/Sites/Default"
DirectoryIndex index.html index.php default.html
CustomLog "/var/log/apache2/access_log" combinedvhost
ErrorLog "/var/log/apache2/error_log"
<IfModule mod_ssl.c>
SSLEngine Off
SSLCipherSuite "ALL:!aNULL:!ADH:!eNULL:!LOW:!EXP:RC4+RSA:+HIGH:+MEDIUM"
SSLProtocol -ALL +SSLv3 +TLSv1
SSLProxyEngine On
SSLProxyProtocol -ALL +SSLv3 +TLSv1
</IfModule>
<Directory "/Library/Server/Web/Data/Sites/Default">
Options All -Indexes -ExecCGI -Includes +MultiViews
AllowOverride None
<IfModule mod_dav.c>
DAV Off
</IfModule>
<IfDefine !WEBSERVICE_ON>
Deny from all
ErrorDocument 403 /customerror/websitesoff403.html
</IfDefine>
</Directory>
ProxyPass /__collabd/streams/activity balancer://balancer-group-webapp-com.apple.webapp.collabd--__collabd-streams-activity
...
</VirtualHost>


You can see that the document root is /Library/Server/Web/Data/Sites/Default, and that directory has some options set for it. One of those options is -Indexes which disables the generation of auto-indexes when a suitable index specified by DirectoryIndex cannot be found. If you remove -Indexes and restart apache, you should find that the document root will return a directory listing when you access your web server. You could also change the document root to point somewhere else; I strongly advise against pointing it at someplace like "/" or "/Users/".

I did what you said, and now if I surf to 192.168.1.XXX I get a blank web page. I have attached to this post the conf file I have edited and the default one, so that you can check them and see if I did something wrong.

ElectricSheep
Aug 20, 2013, 05:25 PM
I did what you said, and now if I surf to 192.168.1.XXX I get a blank web page. I have attached to this post the conf file I have edited and the default one, so that you can check them and see if I did something wrong.

Based on the config file you uploaded, navigating to 192.168.1.XXX/ will not serve "/Volumes/Server data/Library/Server/Web/Data/Sites/Default". You have set the DocumentRoot to "/Volumes/Server data/", but have not specified any options for that path with a matching <Directory "/Volumes/Server data/"></Directory>.

You would have to navigate to 192.168.1.XXX/Library/Server/Web/Data/Sites/Default/.

jomobco
Aug 20, 2013, 09:00 PM
Index.html is what I use. It seems to overwrite the default.html when I publish to the web folder (I have multiple domains from a single IP). It's easy to start over where you are. Just delete the default folder and reconfigure like you're re-setting up the domain folder in the website management. If you accessed the default page (welcome to server) from the internet than you've got everything pointed in the right direction. It's stupid simple once you get the hang of it. :D

It's simple to tell where you publish to. Just go through the steps like you're adding a second domain and see where it gets placed. You can also use this opportunity to determine where you'd like to place your website folders.

Jaggions
Aug 21, 2013, 04:51 AM
Based on the config file you uploaded, navigating to 192.168.1.XXX/ will not serve "/Volumes/Server data/Library/Server/Web/Data/Sites/Default". You have set the DocumentRoot to "/Volumes/Server data/", but have not specified any options for that path with a matching <Directory "/Volumes/Server data/"></Directory>.

You would have to navigate to 192.168.1.XXX/Library/Server/Web/Data/Sites/Default/.

I fixed that in the conf file, and now surfing to any path after 192.168.1.XXX just doesn't load the page. I wonder what I'm doing wrong! :confused: I feel soo stupid!

EDIT: After a reboot now the pages load again, but I get the same errors as before.
Again, I'll upload my configuration file. Thank you very much for your patience and for your help.