0 Install joplin vieweb on a local web server, and access it externally from a subdomain through apache2
Nicolas Guillot edited this page 2023-01-09 20:01:08 +01:00

This procedure has been written by Eliness, thanks to him ❤

MEGA DISCLAIMER: I'm quite a beginner in all of this so surely some of these instructions are approximate if not wrong. I'm far from claiming the following process is secure nor optimal. This is only how I got things to work, any suggestion for improvement is more than welcome :)

The context is: you have a selfhosted web server with apache2 running, and you want to install joplin-vieweb on it and access it from an external subdomain (https://sub.domain.net in the following instructions).

Install joplin-vieweb on your server through docker

Download the docker-only yaml file and edit the following parameters:

  • Line 4: ORIGINS: Adresses from which you want to be able to connect to joplin-vieweb. ORIGINS: "'http://localhost', 'http://localipofserver','https://sub.domain.net"
  • Line 15: ports: two port numbers. The first one of your choice (I used 1234), is the one on your server which will be redirected to the second one in your container.
  • - 1234:8000

Then on the command line in the same folder than the yaml file, run the containers in detached mode: docker-compose up -d

On your web server, check that you can access http://localhost:1234/admin From your local network, check that you can access http://localserverip:1234/admin

Set joplin-vieweb up

Follow the instructions of Configurations and usage in the doc.

Once the sync is done, if your notes are encrypted they should not display properly. You need to run the decryption using the following command line from your server: docker exec -ti joplin-vieweb_joplin-terminal-xapi_1 joplin e2ee decrypt It will ask for your Joplin master key and will take some time to decrypt the files. It happened to me that the decryption interrupted and returned an error because Joplin started syncing at the same time. If so, just wait for the sync to finish then re-run the decryption command.

You should now be able to access your notes on your local network using http://localserverip:1234/joplin

Access your notes from the outside: Create an apache2 VirtualHost file which will redirect your subdomain

Let's assume your subdomain is: http://sub.domain.net (we'll tackle https later).

In /etc/apache2/sites-available, create the following subdomain.conf file:

<VirtualHost _default_:80>
ServerName sub.domain.net
ProxyPreserveHost On
<Location />
        ProxyPass http://localhost:1234/
        ProxyPassReverse http://localhost:1234/
        Require all granted
        Options none
</Location>
</VirtualHost>

Then relaunch apache2 with the following: sudo systemctl restart apache2

Redirect your subdomain to the server IP

This depends on your domain provider service, there should be a parameter in the administration where you can use an A redirection to redirect http://sub.domain.net to the public ip address of your server. To get the latter, I used the following command line: curl icanhazip.com.

Now you should be able to access joplin-vieweb from anywhere on the following address: http://sub.domain.net/joplin

(optional) Generate an SSL certificate and edit the VirtualHost so that joplin-vieweb is accessible through https

You can use certbot to generate an SSL certificate as following: sudo certbot certonly -d sub.domain.net . The path to your keys should be returned as output. Then you need to edit the subdomain.conf file accordingly (note changes in the port of the first line, the added lines and the paths to your keys)

<VirtualHost _default_:443>
ServerName sub.domain.net
ProxyPreserveHost On
<Location />
        ProxyPass http://localhost:1234/
        ProxyPassReverse http://localhost:1234/
        RequestHeader set X-Forwarded-Protocol "https"
        Require all granted
        Options none
</Location>
SSLProxyEngine on
SSLCertificateFile /etc/letsencrypt/live/sub.domain.net/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/sub.domain.net/privkey.pem
</VirtualHost>

You should now be able to access joplin-vieweb from anywhere through https://sub.domain.net/joplin