How do I run PhotoStructure under a virtual directory?

Hi all,

How do I set up PhotoStructure to run under a virtual directory? I’ve tried using nginx to proxy a virtual directory for the library, and I hit the landing page, but then PhotoStructure redirects back to root.

Here’s an example of the setup I want:
Internal: http://localhost:1787

Internal: http://localhost:1887

Internal: http://localhost:1987

In the above, I’m using nginx proxy_pass, and I definitely hit PhotoStructure for the /all, /family and /work virtual directories. But PhotoStructure then directs back to / which doesn’t exist.

Am I missing a setting in Nginx or PhotoStructure to stop this?
Or can I make PhotoStructure run under a virtual directory which would get around it, e.g.:

Internal: http://localhost:1787/*all*

Internal: http://localhost:1887/*family*

Internal: http://localhost:1987/*work*

A simplified version of my nginx.conf is below. I’ve removed SSL, hostname, and other unique details for security.

worker_processes  2;

events {
    worker_connections  1024;

http {
	server_names_hash_bucket_size  64;
    include       mime.types;
    default_type  application/octet-stream;
    sendfile        	on;
	server_tokens 		off;
    keepalive_timeout  	65;
	proxy_http_version 	1.1;
	proxy_set_header Connection "";

	server {
		listen 443 default_server;
		location /all {
			auth_basic  "Restricted";
			auth_basic_user_file  xx1.pwd;
			proxy_pass http://localserver:1787;
		location /family {
			auth_basic  "Restricted";
			auth_basic_user_file  xx2.pwd;
			proxy_pass http://localserver:1887;

		location /work {
			auth_basic  "Restricted";
			auth_basic_user_file  xx3.pwd;
			proxy_pass http://localserver:1987;

		location / {
			return 404;

Any help appreciated, thanks

I could be wrong, but I think you would need to run three different Photostructure servers in order to accomplish this. One server for all, one for Family, and one for Work.

Sorry, I missed the different ports. My attention to detail is lacking, but in my defense I just got done with a 3 week vacation!

@tkohhh He currently is running three instances — that’s where the three different ports are coming from.

@awojtas, I’ve used absolute paths everywhere (both in the fronted router and backend router). It turns out that relative pathing is a bit of a bear to manage when URLs have arbitrary depth (like /tags/fs/foldername/subfolder/…).

I just found that Express supports mounting routers on subpaths using .use, so this may not be the nightmare I was expecting–I basically can keep my absolute paths, but add a new setting (that defaults to /) to absolute-ify paths (instead of just hard-coded /)

I’d also need to be able to send this sub-path to the frontend to let that router handle things properly as well.

(What would a good name for this setting be? webserverMountpoint? httpLocation? )

(I’m changing this to be a feature request and voting for it)

Thanks for the reply, yup @mrm you got my use-case, and appreciate the clarification that PS can’t currently do this because it expects absolute paths everywhere, helpful to know so I won’t keep banging my head against a wall trying to make it work.

I’ll keep checking back every so often in case this changes one day and it can support being hosted in a virtual directory.

I think a good setting name would be “virtualDirectoryPath”, and the default value is “/”, which is current behaviour. But you can override it with whatever you like.

Is this feature required to run PhotoStructure behind nginx, or just to support multiple instances on the same machine? I’m looking to run PS behind nginx (a single instance), but I’m running into the same url rewriting issue.

For what it’s worth, I remember having to do something similar when running Radarr/Sonarr/etc. You can specify a urlBase to support reverse proxying:

and then your nginx proxy config looks like:

 proxy_pass http://radarrjail.local:7878/radarr;
 proxy_set_header Host $host;
 proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
 proxy_set_header X-Forwarded-Host $host;
 proxy_set_header X-Forwarded-Proto https;
 proxy_redirect off;

 proxy_http_version 1.1;
 proxy_set_header Upgrade $http_upgrade;
 proxy_no_cache $cookie_session;
 proxy_set_header Connection $http_connection;

 access_log /var/log/nginx/radarr.access.log;
 error_log /var/log/nginx/radarr.error.log;