Greetings, digital explorers! In this thrilling quest, we’re diving deep into the world of web hosting, wielding the formidable tools of Docker, Nginx, and the enchantments of Certbot. Our destination: a robust MediaWiki setup that rivals the very engine driving Wikipedia.

Picture this journey as a continuation of our previous odyssey, where we explored the seas of Docker to anchor our MediaWiki. If you missed that adventure, fear not, for the tale awaits in our earlier article. Now, armed with the knowledge from our Docker escapade, we’ll extend the capabilities of our MediaWiki using Nginx as a trusty navigator and sprinkle in a bit of Certbot magic for an extra layer of security.

But that’s not all! Stay tuned, as we’ve also penned an article on how to further enhance your MediaWiki’s prowess when hosted with Docker. Together, let’s sculpt a digital realm where knowledge not only flows but surges through the web with unparalleled grace.

Join us, intrepid ones, as we embark on this exciting expedition towards a seamless, secure, and infinitely expandable MediaWiki hosting experience. The stage is set, the tools are at our disposal – let the adventure unfold! 🌐⚙️✨

Prerequisites: Ready, Set, Launch!

Gather Your Tools

Before we dive into the sea of wikis, ensure you have Docker and Docker Compose installed on your server. You wouldn’t want to navigate these waters without a trusty vessel.

Claim Your Domain

Secure a domain name and point it to your server’s IP address. Think of it as naming your ship; a domain adds character to your digital journey.

Setting Sail with Docker Compose

Our first port of call is setting up MediaWiki using Docker Compose. Think of Docker Compose as your trusty first mate, coordinating the crew (containers) effortlessly.

Create docker-compose.yml

# Your ship's manifest
version: '3'

    # Image of your ship
    image: mediawiki
      - "8080:80"
      - MYSQL_ROOT_PASSWORD=mysecretpassword
      - MYSQL_DATABASE=wikidb
      - MYSQL_USER=wikiuser
      - MYSQL_PASSWORD=wikipassword
      - ./mediawiki/images:/var/www/html/images
    restart: always

    # The ship's cook - MySQL
    image: mysql:5.7
      MYSQL_ROOT_PASSWORD: mysecretpassword
      MYSQL_DATABASE: wikidb
      MYSQL_USER: wikiuser
      MYSQL_PASSWORD: wikipassword
    restart: always

Note: Customize the database credentials to suit your taste. Now, shout the command:

docker-compose up -d

And behold, your MediaWiki ship rises from the digital waves!

Ahoy! Now that our wiki ship is afloat, let’s tame the seas with Nginx, our trusty navigator and reverse proxy.

Craft Your Nginx Configuration

Create nginx.conf – the map guiding your ship through the vast internet ocean:

# The sailor's song
server {
    listen 80;

    location / {
        proxy_pass http://localhost:8080;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;

Replace with the North Star of your digital quest. Next, strap this map to the ship:

docker run -d -p 80:80 -v /path/to/nginx.conf:/etc/nginx/nginx.conf:ro nginx

Hoisting the Sails of SSL with Certbot

In our digital odyssey, security is our trusty first mate, and SSL, our formidable shield against lurking sea monsters in the vast online ocean. Picture SSL as the gleaming armor that safeguards your MediaWiki fortress, shielding it from the prying eyes of digital marauders.

As we raise the sails of SSL with the aid of Certbot, envision the cloak of encryption enveloping your MediaWiki installation. SSL, or Secure Socket Layer, works as the vigilant guardian of your data. It’s like having a discreet whisperer between your users and your wiki, ensuring that every communication remains confidential and impervious to eavesdropping.

Consider this: when your users log in to your MediaWiki realm, SSL stands sentinel, encrypting the transmission of their sensitive credentials. It’s akin to speaking in an exclusive code that only your server and the rightful user can decipher. No more worrying about passwords being intercepted by unseen digital pirates!

So, as we fortify our ship against potential adversaries, SSL emerges as the knight in shining armor, keeping your MediaWiki safe from the shadows of the online seas. With Certbot as our wise sorcerer, enchanting the realm with secure connections, our digital voyage becomes a triumph over potential security threats.

Prepare to sail confidently, knowing that SSL is the guardian at the gates, ensuring that your MediaWiki’s secrets are kept safe from the eavesdropping ears of the digital deep. Onward, valiant navigator, into the secure and fortified waters of SSL protection! ⚓️🔒💻

Summon the Certbot Sorcery

Install Certbot with a magical incantation:

sudo apt-get update
sudo apt-get install certbot python3-certbot-nginx

Cast the spell:

sudo certbot --nginx -d -d

Answer the wizard’s questions, and Certbot shall weave its SSL enchantments.

Fortifying the Ship: SSL in Nginx

Our ship now cruises through secure waters. Let’s tweak Nginx’s sails for SSL.

Enhance nginx.conf for SSL

Modify your nginx.conf for the grand SSL voyage:

# The captain's speech
server {
    listen 80;
    return 301 https://$host$request_uri;

server {
    listen 443 ssl;

    ssl_certificate /etc/letsencrypt/live/;
    ssl_certificate_key /etc/letsencrypt/live/;

    location / {
        proxy_pass http://localhost:8080;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;

Replace with your digital vessel’s name.

Anchors Aweigh: Restarting Nginx

The final step before celebrating our successful voyage is to restart Nginx. A small adjustment, a mighty salute!

docker restart your-nginx-container-id

Sailing into the Future of MediaWiki Hosting

Bravo, fellow captain of the digital seas! You’ve now successfully navigated the intricate waters of setting up MediaWiki with Docker and anchoring it securely with an Nginx reverse proxy. As we lower the anchor and secure our sails, let’s cast a forward-looking gaze at the horizon.

Elevating Your MediaWiki Experience

By configuring Nginx as a reverse proxy for your MediaWiki instance, you’ve not just streamlined access but paved the way for a seamless and secure user experience. Your visitors will now encounter a swift and well-protected harbor of information.

Unveiling the Power of Nginx

Nginx, with its prowess as a high-performance web server and reverse proxy, adds a layer of optimization to your MediaWiki setup. Your content delivery will be expedited, ensuring that users can navigate your digital shores effortlessly.

Security, the Silent Guardian

In this age of online complexities, the Nginx reverse proxy stands as a vigilant guardian, warding off potential threats and ensuring the safe passage of data. Your MediaWiki fortress is fortified against unauthorized access, giving your users the confidence to explore without hesitation.

Charting New Territories

As you bask in the success of your MediaWiki deployment, remember that the digital seas are ever-evolving. Stay tuned to the winds of technology, for future enhancements and optimizations await your command.

Fair Winds and Prosperous Seas

May your Nginx-anchored MediaWiki continue to be a beacon of knowledge in the vast ocean of the internet. Here’s to smooth sailing, uncharted discoveries, and the continual growth of your digital empire.

Fair winds, savvy captain! Until the next chapter of your digital odyssey unfolds. 🚢⚓️

Bonus Section: Turbocharging Your MediaWiki with Nginx Caching

Ahoy, fearless navigators! As you bask in the success of your MediaWiki setup with Docker, Nginx, and Certbot, let’s unfurl the sails of performance optimization. Brace yourselves for the bonus round, where we’ll delve into the realm of Nginx caching, transforming your MediaWiki into a swift and responsive vessel.

The Need for Speed

Just as a swift ship conquers the ocean with grace, a fast-loading wiki conquers the vast realm of the internet. Nginx caching acts as the tailwind, propelling your MediaWiki to new heights by storing frequently accessed content for rapid delivery.

Setting Up Nginx Caching

  • Nginx Configuration: Open your Nginx configuration file, usually located at /etc/nginx/nginx.conf or /etc/nginx/sites-available/default.
  • Add Caching Directives: Introduce the following lines within the server block:
proxy_cache_path /path/to/cache levels=1:2 keys_zone=my_cache:10m max_size=10g inactive=60m use_temp_path=off;

Replace /path/to/cache with the desired cache directory on your server.

  • Apply Caching to Locations: Within your location blocks, apply caching based on your preferences. For instance:
location / {
    proxy_cache my_cache;
    proxy_cache_valid 200 302 5m;
    proxy_cache_valid 404 1m;
    proxy_pass http://localhost:8080;
    # ... other proxy settings
  • Restart Nginx: Execute the command to restart Nginx and activate the caching changes:
sudo service nginx restart

Revel in the Speed Boost

With Nginx caching in place, your MediaWiki content becomes a well-oiled machine, serving pages with lightning speed to eager visitors. Frequently accessed pages are cached, reducing the strain on your server and ensuring a smoother user experience.

So, set your sights on the horizon, fearless sailors, as Nginx caching propels your MediaWiki to navigate the digital seas with unparalleled speed and efficiency. Enjoy the exhilarating ride! 🚀⚓️💨