Skip to content

Examples nginx, apache

Blexyel edited this page Jun 7, 2024 · 4 revisions

Nginx setup

This Example will show you both, how to serve the songs publicly and how to host this instance behind a reverse proxy!

Requirements:

  • A server
  • A domain (technically optional)
  • A static IP (You can check out Cloudflare's Documentation for dynamic IP's)
  • IPv6 (Optional) Check here or curl -6 ifconfig.me. An IPv6 Address looks something like this: 2345:0425:2CA1:0000:0000:0567:5673:23b5
  • nginx (should be obvious)
  • certbot or similair (Optional, but recommended)

Dependencies

Arch linux

pacman -S nginx certbot certbot-nginx

Ubuntu / Debian

apt install nginx certbot python3-certbot-nginx

Other distros (Documentation needed)

Example config

Note

I personally use /srv/sfh/songs to store and serve the songs, but this can be changed to any directory you like.

# SFH mirror software reverse proxy
server {
    server_name <your-domain.name>;
    # Only enable, if you have IPv6! Check here: http://ifconfig.me
    # listen [::]:80;
    # listen [::]:443;
    listen 80;
    listen 443;

    location / {
        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;

        proxy_pass http://127.0.0.1:58532/;
        proxy_buffering on;
        proxy_redirect off;

        # websocket
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection $connection_upgrade;
    }
}


# Public song host
server {
    server_name <your-domain.name>;
    listen 80;
    # Only enable, if you have IPv6! Check here: http://ifconfig.me
    # listen [::]:80;
    # listen [::]:443;
    listen 443;

    root /srv/sfh/songs;
    autoindex on;
}

Important

You should definitely use certbot or something similair, to secure your website/s. You can do this by running certbot --nginx and following the instructions on screen

Song hosting (This section also applys to Apache)

To actually get the songs in the correct directory, you could run ln -s directory/of/sfh-mirror/repo/songs /srv/sfh/songs and make the folder owned by the user the sfh mirror is actually running on: chown user:user /srv/sfh/songs. To check your username, you can simply run whoami.

Apache setup

Requirements:

  • A server
  • A domain (technically optional)
  • A static IP (You can check out Cloudflare's Documentation for dynamic IP's)
  • IPv6 (Optional) Check here or curl -6 ifconfig.me. An IPv6 Address looks something like this: 2345:0425:2CA1:0000:0000:0567:5673:23b5
  • apache (should be obvious)
  • certbot or similair (Optional, but recommended)

Arch linux

pacman -S apache certbot certbot-apache

Ubuntu / Debian

apt install apache2 certbot python3-certbot-apache

Other distros (Documentation needed)

Example config

Note

Still has to be documented, since I (@PassiHD2004) am not very experienced with apache!