nginx reverse proxy mopidy raspberry pi 2

nginx mopidy

In this post :
I showed you how to create a mopidy raspberry pi config.
I also created a nginx reverse proxy tutorial:
If you use the Nginx reverse proxy you can easily navigate to your mopidy installation without remembering the port numbers.

Let’s get started by installing nginx.

apt-get install nginx

Now we need to configure nginx to redirect our request to the correct webinterface. But first let’s check if nginx installed succesfully by going to the ip adres of the pi. In my case, if all went well you should see something like this:

Now it’s time to go to the config directory of Nginx sites.

cd /etc/nginx/sites-available/

Now create a new config called mopidy.

vi mopdiy

Now we need to make Nginx listen on port 80, and redirect all traffic to the webinterface.

server {
    listen  80; 

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

In my case i want mopidy to redirect to spotmop on port 6680. Since i have nothing else but mopidy on my pi i can easily redirect all traffic coming from port 80 to spotmop.

Now save the file, and create a symbolic link. Go to the sites-enabled directory.

cd /etc/nginx/sites-enabled

First delete the existing symlink, so we won’t see the welcome to Nginx page all the time.

rm default

Now create the new one.

ln -s ../sites-available/mopidy mopidy

Now it’s time to restart nginx, and test the config.

service nginx restart

If done correctly you should end up with a redirection to the spotmop on port 6680.

If not, leave a comment so we can help you solve the issue.

Leave a comment

Your email address will not be published. Required fields are marked *