Hosting a website on WD My Cloud

Hello,

I just want to host a simple page listing the files in the WD on a domain name that I can access from outside my network.

However, the solution in this topic http://community.wd.com/t5/WD-My-Cloud/MyCloud-as-Web-Site/td-p/684127 doesn’t work on the latest firmware since virtualhosts syntax has changed.

If I try to add a simple vhost in the /sites-enabled folder, I get a cannot occur within section.

There must be something in Apache’s config that I’m missing, but I don’t see it.

Thanks :slight_smile:

Hello, this is not officially supported, but maybe some of the other users can share some advice. 

I would say, install the

  • clean debian from Fox_exe (see thread)

  • and then owncloud

If you would like too stay on the current firmware, please show us the configs. I think not that wd has

changed the syntax of apache.

Thanks for the answer. I’m fine with WD’s firmware at the moment, it does everything I expect from a NAS and I don’t see which benefits I could get from OMV.

Here are the config files:

Apache2.conf loads:

IncludeOptional ${SERVER_ROOT}/conf.d/*.conf

in this folder, we have

additional-httpd.conf

Document root will point to /var/www/htdocs

DocumentRoot ${DOCUMENT_ROOT}
ServerAdmin webmaster@localhost
ServerName localhost

define default language

<IfModule mod_mime.c>
    DefaultLanguage en
    AddLanguage en-us .en
    AddLanguage fr-fr .fr
    AddLanguage it-IT .it
    AddLanguage de-DE .de
    AddLanguage es-ES .es
    AddLanguage zh-TW .zht
    AddLanguage zh-HK .zhk
    AddLanguage ja-JP .ja
    AddLanguage ko-KR .ko
    AddLanguage ru-RU .ru
    AddLanguage pt-BR .pt

########

TODO: Need to figure out where to handle this: who’s in charge of the default error pages?

###############

Enabling server-side includes for error pages.

<Directory ${DOCUMENT_ROOT}>
  AllowOverride none
  Options MultiViews IncludesNoExec FollowSymLinks
  AddType text/html .shtml
  <FilesMatch “.shtml[.$]”>  # Limit the scope of this directory directive to only .shtml files
    SetOutputFilter INCLUDES
 

“400 Bad Request”,

ErrorDocument 400 ${DOCUMENT_ROOT}/errordocs/400/400

“401 Authorization Required”,

ErrorDocument 401 ${DOCUMENT_ROOT}/errordocs/401/401

“403 Forbidden”,

ErrorDocument 403 ${DOCUMENT_ROOT}/errordocs/403/403

“404 Not Found”,

ErrorDocument 404 ${DOCUMENT_ROOT}/errordocs/404/404

“500 Internal Server Error”,

ErrorDocument 500 ${DOCUMENT_ROOT}/errordocs/500/500
###########

    Options FollowSymLinks     AllowOverride None

<Directory ${DOCUMENT_ROOT}>
    Options +FollowSymLinks +MultiViews -Indexes
    AllowOverride All
    Require all granted

    
ErrorLog ${APACHE_LOG_DIR}/error.log

Include the virtual host configurations:

IncludeOptional ${SERVER_ROOT}/sites-enabled/*.conf

SSL

<VirtualHost *:443>
    <IfModule mod_ssl.c>
        SSLEngine on
        
        <FilesMatch “.(cgi|shtml|phtml|php)$”>
            SSLOptions +StdEnvVars
        

        BrowserMatch “.*MSIE.*” \
            nokeepalive ssl-unclean-shutdown \
            downgrade-1.0 force-response-1.0
        
        IncludeOptional /etc/nas/apache2/server-name.conf
    

    # Enable “sites” on https port
    IncludeOptional ${SERVER_ROOT}/sites-enabled/*.conf
    

In sites-enabled , we have

wdnas-rest-api.conf

SetEnv __ADMIN_API_ROOT ${REST_API_ROOT}
LogLevel error

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteRule   ^/api/([0-9.]+)/rest/(.*)  /api/rest/index.php [L]

<IfModule mod_rewrite.c>
    # configure landing page for webdav applet
     RewriteRule ^/LandingPage /mapdrive/securityCheck.php [L]

####################

WebDav extension

####################
<Ifmodule dav_module>
    Include /etc/nas/apache2/auth/alias.inc
    Include /etc/nas/apache2/auth/require.inc

<IfModule mod_ssl.c>
    # Rest API certificate files.
    SSLCertificateFile /var/www/rest-api/config/server.crt
    SSLCertificateKeyFile /var/www/rest-api/config/server.key

wdnas-ui.conf

<IfModule mod_rewrite.c>
    <Directory “${DOCUMENT_ROOT}/UI”>
        ${LOCAL_NET}
        RewriteEngine On
        RewriteBase /UI/
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteRule ^(.*)$ /UI/ [R]
    

As you can see, additional-httpd.conf is slighly different from the file posted in the thread I’ve linked to above. When I try to add a website adding a new file in sites-enabled like I’d do on a regular Debian running Apache, I get the virtualhost within virtualhost error. I’m pretty sure that’s caused by the additional-httpd.conf but I can’t figure out why.

Merry xmas guys :slight_smile:

You do not have to touch any of the WD’s original config. Just create a new vhost conf file. But in the new vhost conf file you need to include WD’s original config else WD Dashboard will break. After configuring, just reload Apache2.

I have wordpress and owncloud7 running on the latest v4.

Thanks for the answer.

Can I see your vhost? I was doing something lke

<VirtualHost *:80>
    DocumentRoot /var/www/myfolder
    ServerName mydomain.net

without success.

Add ServerAlias directive.

I’m sorry, I don’t understand what you mean?

<VirtualHost *:80>
    DocumentRoot /var/www/myfolder
    ServerName mydomain.net

    ServerAlias *.mydomain.net

Place these under conf.d path. Anyway I’ve switched to Nginx as I found it’s much faster and still able to access WD Dashboard. You can preview one of the few sites hosted on my WDMyCloud 4TB http://nazar.bagus.org/

Thanks for the answer. i’ve put the file in /conf.d but I’m still getting a

Forbidden

You don’t have permission to access /UI on this server.

Additionally, a 403 Forbidden error was encountered while trying to use an ErrorDocument to handle the request.

and a redirect to mydomain/UI when I try to visit it. I think I’ll give up.

Thanks anyway.

PS: I use Nginx on my webserver, it’s so much better than Apache!

You’re getting redirected to the UI page mainly due to the following reasons:

  1. Have you reloaded apache? “service apache2 reload”.

  2. Have you cleared your browser’s cache?

  3. I don’t think this is your case but I’ll just put it in the list. In your new config you defined host mydomain.net but you browse using ip instead of mydomain.net thus apache couldn’t identity the vhost and use the default. Or the DocumentRoot still pointing to the default WD location.

Actually Apache is great and fast. But due to WD’s config of using mpm_prefork and php5_mod, the server needs lots of resources to hold fair amount of traffic which our nas is lacking especially the 256mb ram mainly. I modded and switched to threaded mpm_event + mod_fastcgi + php5-fpm, removed all the unnecessary modules, now apache is smooth and fast.

Below is one of my configs in the conf.d path. You can ignore the mod_fastcgi part unless you already modded them. I modded Apache2 to run Perl’s FCGI and Php5-fpm:

<IfModule mod_fastcgi.c>
	AddType application/x-httpd-fastphp5 .php
	AddType application/x-httpd-fcgi .fcgi
	Action application/x-httpd-fastphp5 /php5-fcgi
	Alias /php5-fcgi /usr/lib/cgi-bin/php5-fcgi
	FastCgiExternalServer /usr/lib/cgi-bin/php5-fcgi -socket /var/run/php5-fpm.sock -idle-timeout 300 -pass-header Authorization
	<Directory /usr/lib/cgi-bin>
		Require all granted
	</Directory>
</IfModule>

<VirtualHost *:80>
	include /etc/apache2/sites-enabled/*.conf
</VirtualHost>

<Directory />
	Options +ExecCGI +FollowSymLinks +MultiViews -Indexes 
	AllowOverride All
	Require all granted
	AddHandler cgi-script .cgi .pl
	DirectoryIndex index.fcgi index.cgi index.pl index.php index.htm index.html default.htm
</Directory>

<VirtualHost *:80>
	DocumentRoot /DataVolume/wordpress
	ServerName nazar.bagus.org
	ServerAlias nazar.bagus.org
	include /home/Nazar/.config/apache2-rewrite.conf
</VirtualHost>

Nazar78 wrote:

I have wordpress and owncloud7 running on the latest v4.

Nazar, could you maybe start a new thread with up-to-date instructions for installing OwnCloud (or WordPress, etc.) on v4? (The old thread “OwnCloud” is a little convoluted.)

My basic idea would be to install PHP5 from the repo of @Fox_exe, make a new vhost conf file and then install OwnCloud by one of the official methods (tar, php script or deb - which one?). But I am not really confident and would very much appreciate a detailed instruction with best practices from your exhaustive experience.

Thanks for your continuous contrribution!

@Flexpert

Thanks for the encouragement. My aim is to make a guide without breaking WD’s stuffs or bricking the nas itself. So unless one really knows his/her way around linux, using apt-get in a guide is a no go for me as there’ll be too much to answer if things gone wrong.

Adding Php5-gd/MySQL will definitely break something. I also had to upgrade both Apache2 and Php5 due to miss matched modules after adding php5-gd/MySQL. My first try was apache couldn’t start, then WD’s email stopped working and the list goes on. After all those effort, I still remember during the firmware v3 days, even we have the old good apt-get to play around but OwnCloud took ages to load.

But recently I think I hit the jackpot! Wordpress and Owncloud7 loads pretty quickly both on Apache2 and Nginx. A new online installer for v4 firmwares should be out soon to host WP/OC etc, new year or after maybe? Do keep a lookout on the main forum. I’m still tweaking the configuration scripts…

Most likely, you are being redirected to /UI/ because by default, apache2 catches access from port 80 and sends you index.html at /var/www/htdocs/, which is like this:

<html>
        <head></head>
        <body>
                <script type="text/javascript">
                <!--
                window.location = "/UI";
                //-->
                </script>
        </body>
</html>

 and that sends you to /UI/.

In my case I edited index.html to redirect at folder containing wanted site, since I used apache2 to host my site. Don’t know how I can fix that when using Nginx.

@Sarka

We could edit the index.html in the htdocs but this would break the original WD’s setup e.g. if accessed from upnp. No biggy for some as we could just add /UI/ to the URI.

Doing this with a vhost is much preferred as it doesn’t break upnp access and lesser redirects on the site e.g. 301->302?->window.location.

For Nginx we’ll need to do some modifications to Nginx itself and Apache2 using rewrites. With this I can access both my site http://nazar.bagus.org and WD Dashboard  http://wdmycloud.