Need help to host your simple private website or save future cost by migrating your simple SME company’s website to your personal NAS such as WDMyCloud? For a generous donation you can make it work! Professional freelance web coding design services are also available for your needs. Do send in your enquiries.
This guide has been separated for generic implementation of WebHosting on the WDMyCloud V4 Firmwares. Purpose of this guide is mainly for those who’s new to personal web hosting (maybe Linux itself) and interested in running sites like OwnCloud or WordPress on their WDMyCloud firmware v4 NAS. If you’re not familiar with HTTP Servers and CGIs, then maybe this is not for you.
Why Nginx not Apache2? Apache2 is great but when there’s multiple or concurrent connections, the WD’s Apache2 MPM_PREFORK and MOD_PHP5 configs may cause lots of swapping as they have high memory print thus slowing down everything with high I/O Wait. At some point you’ll need to unplug the power as even SSH not responding.
Disclaimer: As I’m frequently updating the original guides and installers here on TeaNazaR.com, I will not be responsible for any brick issues if you were to follow my obsolete guides copied elsewhere. Thus subscribe to this post to get latest updates. Modifying any part of a device may void its warranty.
WDMyCloud is a pretty small server, dual-core ARM Cortex-A9 650MHz CPU with 256MB DDR3 RAM running on Debian Wheezy OS. But with some mods, tweaks and caches, it should be able to host a small personal site (not those thousands daily hits). The idea here is to switch Apache2 to a lower memory consumption threaded MPM_EVENT process which is compatible with PHP5-FPM and together with a light-weight Nginx, hopefully there’ll be lesser swapping. We can’t totally remove Apache2 because lots of WD’s stuffs depends on it like WebDav remote login for example will require revamp of the PHP scripts.
1) Get free DNS forwarder if not done so [Optional]
To easily access your WDMyCloud without needing to remember your external ISP IP address especially if it’s dynamic, get those easy to setup and free Dynamic DNS forwarder such as http://freedns.afraid.org/signup/moreinfo/. They provide free DDNS forwarding up to 5 subdomains. Your router many already have such DDNS service but I find it rather limited. I’m using GoDaddy’s DNS service which bundled with my paid domain (www.TeaNazaR.com). Tips: If your owned domain provider doesn’t provide an easy method of updating your dynamic ISP IP, you can also make use of this freedns service by pointing your owned domain CName (Alias) to the freedns subdomain. Cool huh? (-:
Updated: If you’re using GoDaddy’s DNS service, do refer to my latest GoDaddy DDNS Updater post.
After reading the FAQ and signing up with email confirmation, login and click on the left “Registry” menu to find a nice suitable DNS for yourself like “mooo.com”, click on it. On the next page, all you need to submit is your “Subdomain” e.g. my-freedns-subdomain.mooo.com. Note this down if you’re setting up OwnCloud or WordPress from my other guides as we’ll need it later to setup Nginx’s “server_name“. Leave the rest as default. Next we’ll need to ensure the DNS is always up-to-date with your ISP IP address. Click on the left “Dynamic DNS” menu where you’ll see your new DNS list, right-click and copy the link “Direct URL“. The URL should point to something like http://freedns.afraid.org/dynamic/update.php?RllWcksfRUY5afdyUGNgdVcwQs43ejROhjEyNTfxgjQw. Then schedule a 5mins repeating cronjob on your WDMyCloud to automatically update the DNS incase your ISP IP address changes. SSH into your WDMyCloud, issue crontab -e and add a new line:
*/5 * * * * /usr/bin/curl freedns.afraid.org/dynamic/update.php?RllWcksfRUY5afdyUGNgdVcwQs43ejROhjEyNTfxgjQw >/dev/null 2>&1
When done, “CTRL+x” to exit and “y” to save changes to the file.
Note that if you have several subdomains, obviously you’ll need one cronjob for each to auto update the DDNS unless if you have enabled the “Link updates of the same IP together” option. This option allows you to update the subdomains of the same IP all at once. Useful if you have several subdomains all pointing to your current ISP IP address so you can just trigger one update. I’m not using this option because sometimes I need some of the subdomains to be pointed elsewhere.
Test out once if it’s working, issue the same command and you should get ERROR: Address 184.108.40.206 has not changed where “220.127.116.11” is your external ISP IP address which you can find out by Googling “what is my IP“:
2) Prepare your router if not done so
This is usually unnecessary for standard Nginx install which you could just forward the same ports 80/443 between externally and internally. But since we’re integrating with Apache2, you’ll need to perform some changes else there’ll be port conflicts between Nginx and Apache2 as both are by default using ports 80/443.
Forward TCP external port 80 on your router to the WDMyCloud internal IP/HOST address PORT:5080. If port 80 is already taken on your router or port 80 is blocked by your ISP, you can choose other ports like 5080 itself but you’ll then need to specify the port manually when accessing from the internet e.g. http://my-freedns-subdomain.mooo.com:5080/ or http://your-ISP-IP-address:5080/. Also if your forwarded external port is other than 80 due to these two reasons, you’ll need to change all occurrences of Nginx’s fastcgi_param SERVER_PORT $server_port variable to whatever external port you’ve chosen. One example of the occurrences is in /etc/nginx/fastcgi_params.
If you have a valid SSL certificate (HTTPS), forward port 443 to wdmycloud:5443 as well. With the port routing below, you can have multiple websites running on single port 80/443 of your router thanks to Nginx’s “server_name” which is similar to Apache2’s VHOST:
Router TCP port(80) -> WDMyCloud TCP port(5080)
Router TCP port(443) -> WDMyCloud TCP port(5443)
Note however that some routers (especially those ISP bundled) have limited or restricted capabilities i.e.:
a. Lack of PAT. Meaning if you specify a rule to forward external port 80, it can only be forwarded to internal port 80. And since WDMyCloud is already using port 80 for Apache2, you’re left with no choice but to use port 5080 as both external and internal port for Nginx.
b. Unable to route back external port to internal port if the request is being made within LAN. Meaning if you try to browse your ISP IP via LAN, your router will return error. So you’re accessing Nginx from LAN, you’ll need to use internal IP instead of ISP IP.
c. You have more than one router i.e. one for the gateway and the other is set to bridge/AP (Access Point) mode.
These could be overcome but requires much more complex options and changes . Do send in your enquiries if you need personalized support.
3) Prepare your WDMyCloud
You’ll first need to install all the necessary apps (Nginx/PHP5-FPM/Perl/MySQL/ESMTP) tweaked for the WDMyCloud firmware v4, available on my post at the WD Forum. Get them installed at this post here, [APP] WebHosting for firmware V4+. Even though the WDMyCloud is already equipped with Apache2/MOD-PHP5/SQLITE, it’s still very sluggish as mentioned earlier maybe due to high I/O Wait and swap trashing. Sometimes it freezes the WDMyCloud for hours when there’s lots of concurrent PHP request and the only solution is to unplug the power cord. I’ve been trying to tweak it out but I finally gave up and switched to Nginx/PHP-FPM.
4) Prepare sendmail if not done so [Optional]
Some Web Apps uses local sendmail to send out email notifications. With ESMTP, you can simulate Postfix’s sendmail MTA by relaying emails to a SMTP server.
Edit ESMTP config:
You can use your ISP email if you know its settings or example here, Gmail. Edit below as needed:
# Config file for ESMTP sendmail
# The SMTP host and service (port)
# SECURITY WARNING: Do NOT set username and password in the system wide
# configuration file unless you are the only user of this machine. See
# The user name
# The password
# Whether to use Starttls
# The certificate passphrase
# The Mail Delivery Agent
When done, “CTRL+x” to exit and “y” to save changes to the file.
Test out once if it’s working, you should see no output but still receive the email in your inbox:
echo -e "To:$TO\nFrom:$FROM\nSubject:ESMTP Test\n\nHello World" | sendmail $TO;
Now your should be able to host simple websites on the WDMyCloud with Nginx/PHP5-FPM/Perl/MySQL/ESMTP e.g. http://my-freedns-subdomain.mooo.com/ or http://your-ISP-IP-address/ and still able to access your WDMyCloud Dashboard from Apache2 http://wdmycloud/ (or whatever internal IP or hostname you have set it to).
And if at anytime you have issues with any of these web apps like very long response time (especially PHP5-FPM after too much concurrent request will result in swap file trashing), a restart is the best way to resolve it:
service nginx restart;
service apache2 restart;
service php5-fpm restart;
service perl-fcgi restart;
service mysql restart;
Checkout my other related guides for WebHosting:
- Dealing PHP-FPM Crash & Nginx 502 Bad Gateway Error with Shell Scripts
- Dealing PHP-FPM Crash & Nginx 502 Bad Gateway Error with Perl FastCGI
For installing OwnCloud or WordPress on this new setup, refer to my guides below:
58 thoughts on “WebHosting on WDMyCloud V4 Firmwares”
hi Nazar, is there a way to totally uninstall the package e.g. an uninstall script?
The installer had made changes to the WD's core files so there's no quick way to uninstall everything unless you know how to do it manually. However you can reflash the same firmware again to revert the changes without affecting your data. Also the changes should not affect the speed of your MyCloud unless you're hosting something heavy.
how I can update TLS to version 1.3 for using SSL within new browsers ?
You can edit the
ssl_protocols TLSv1.2 TLSv1.3;
Then restart the nginx service:
service nginx restart;
it doesn`t work. I´ve got a log message like this:
2022/02/14 08:17:44 [warn] 6639#0: invalid value “TLSv1.3” in /etc/nginx/nginx.conf:40
Any other idea ?
Hi Ronny, I see now the issue. TLS v1.3 requires nginx v1.13 and openssl 1.1.1. However WDMyCloud openssl is the older version. I can upgrade the nginx part but for the built-in openssl not sure if it will break the NAS dependencies.
Edited: I’ve tried however the dependencies are too old. Forcing upgrade on the libc6 will brick the WDMyCloud.
dpkg: dependency problems prevent configuration of libssl1.1:armhf:
libssl1.1:armhf depends on libc6 (>= 2.28); however:
Version of libc6:armhf on system is 2.17-93.
thanx for your reply, it was just a try.
my account is blocked, can you pls solve the problem.
I noticed you just installed transmission successfully. Did you recently changed the HDD? The credentials are tied only to a single WDMyCloud device.
I was updated the WD to the last firmware to V4.06 – 111, it doesn`t work. After a downgrade to V4.05-353 it´s OK, thanks for your help.