Custom domain for Photo Station on a Synology NAS

János Szurovecz
3 min readSep 19, 2020

--

Synology DSM is a fantastic system that has a lot of powerful applications. One of these is Photo Station. My main problem that unlike other “station” apps in the system, Photo Station does not support custom domain name. But I have a solution for this and you do not even have to get your hands dirty with SSH.

My expectations

  1. Photo Station must be accessible on photo.mydomain.tld
  2. It must support both http and https
  3. Adding /photo to the URL should not be mandatory
  4. It should use a dedicated certificate created only for photo.mydomain.tld

Preconditions

  • I tested it on Synology DSM 6.2.3, but it should work on any 6.x system
  • Photo Station is installed
  • Docker is installed
  • photo.mydomain.tld should point to your public IP address and ports 80 and 443 should be forwarded to your NAS in your router. This also means that http://photo.mydomain.tld/photo should work, Photo Station should be loaded

Let’s do it

In order to redirect to /photo if the path is missing from the URL (as Photos Station is available on that path), we need Nginx. Create a directory /docker/photo-station-redirect, and create a new file here called default.conf. Put the following into this file:

events {
worker_connections 4096;
}
http {
server {
listen 5688;
server_name localhost;
root /usr/share/nginx/html;
location ~ ^(/~[^/]+)?(?:/|/photo)?$ {
return 301 https://photo.mydomain.tld$1/photo/;
}
location ~ ^(/~[^/]+)?/photo/.*$ {
proxy_pass http://192.168.10.11;
}
}
client_max_body_size 0;
}

192.168.10.11 is the internal IP of my NAS, replace this part according to your needs. I use port 5688 that you can change as well, but be sure that port is not used at all.

Download nginx:stable-alpine by opening Docker and finding this image in the Registry tab. Launch the image, click on the Advanced Settings, click Enable auto-restart. On the network tab click on Use the same network as Docker Host. On the Volume tab add a new file, select the default.conf file we created above, the mount path should be /etc/nginx/nginx.conf. Use read only mount. If everything is fine and your Docker container is running then Photo Station should be available on http://192.168.10.11:5688/photo/.

Go to Control Panel/Application Portal/Reverse Proxy. We need 2 new proxies, one for HTTP and one for HTTPS. In both cases use the following values:

  • The source hostname: photo.mydomain.tld
  • The destination protocol: HTTP
  • The destination hostname: localhost
  • The destination port: 5688, or the one you chose above
Reverse proxy in DSM, pointing to another Nginx reverse proxy running in Docker

The source protocol and port is HTTP / 80 and HTTPS / 443 in the HTTP and HTTPS proxies respectively. If everything is fine then Photo Station should be available on http://photo.mydomain.tld/photo/. https://photo.mydomain.tld/photo/ should give you a security warning.

Now the only remaining task is to create a new Let’s Encrypt certificate. Go to Control Panel/Security/Certificate, click add and choose Let’s Encrypt. The domain name should be photo.mydomain.tld and use any of your email addresses. After this point the security warning should be fixed and the redirection to the /photo path should work as expected.

One more extra step: in order to use your custom domain for shared links created in Photo Station, update the related fields on the settings page (/photo/admin_index.php).

Photo Station settings

I hope you are enjoying your publicly accessible Photo Station.

Update (9th November, 2020): The default body size of a HTTP request is limited to 1 MB in Nginx. If you wish to upload images and videos in PhotoStation then increase this limit in the Docker container by adding the client_max_body_size 0; at the end of the configuration file.

Update (8th April, 2021): The Nginx configuration has been updated in order to support Personal Photo Station.

--

--

János Szurovecz

I live in Hungary, have a Program Designer Mathematician master degree. 10 years of experience as Java dev / team lead / architect.