Last active
          October 22, 2025 13:12 
        
      - 
      
 - 
        
Save aveexy/4b2b22b2198636b0a91c7c142ec11b37 to your computer and use it in GitHub Desktop.  
    immich nginx reverse proxy with base url (not a full/complete nginx config) base url is /immich (if you want something other, replace "/immich" with other path 
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | pid /run/nginx/nginx.pid; | |
| error_log stderr; | |
| daemon off; | |
| events { | |
| } | |
| http { | |
| proxy_cache_path /var/cache/nginx/immich_revprox keys_zone=immich_revprox:10m levels=1:2 use_temp_path=off inactive=1d max_size=1g; | |
| server { | |
| listen 0.0.0.0:443 ssl ; | |
| listen [::0]:443 ssl ; | |
| server_name example.com ; | |
| http2 on; | |
| location /immich { | |
| proxy_pass http://192.168.1.100:2283; | |
| rewrite /immich/(.*) /$1 break; | |
| proxy_set_header Accept-Encoding "gzip"; | |
| gunzip on; | |
| proxy_pass_request_headers on; | |
| proxy_buffering on; | |
| proxy_cache immich_revprox; | |
| proxy_cache_valid 200 206 1d; | |
| sub_filter_once off; | |
| sub_filter_types text/html; | |
| sub_filter ' href="/' ' href="/immich/'; | |
| sub_filter ' src="/' ' src="/immich/'; | |
| sub_filter ' action="/' ' action="/immich/'; | |
| sub_filter 'import("/_app' 'import("/immich/_app'; | |
| sub_filter 'base: ""' 'base: "/immich"'; | |
| location /immich/_app/immutable/chunks { | |
| sub_filter_types *; | |
| sub_filter '"/api/socket.io"' '"/immich/api/socket.io"'; | |
| proxy_pass http://10.8.1.1:2283; | |
| rewrite /immich/(.*) /$1 break; | |
| } | |
| location ~ /immich/_app/immutable/chunks/(index|app)\\. { | |
| sub_filter_types *; | |
| sub_filter '"/' '"/immich/'; | |
| proxy_pass http://10.8.1.1:2283; | |
| rewrite /immich/(.*) /$1 break; | |
| } | |
| location ~ /immich/_app/immutable/chunks/constants { | |
| sub_filter_types *; | |
| sub_filter '="/' '="/immich/'; | |
| proxy_pass http://10.8.1.1:2283; | |
| rewrite /immich/(.*) /$1 break; | |
| } | |
| location ~ /immich/_app/immutable/chunks/asset-utils { | |
| sub_filter_types *; | |
| sub_filter 'basePath:"/api"' 'basePath:"/immich/api"'; | |
| proxy_pass http://10.8.1.1:2283; | |
| rewrite /immich/(.*) /$1 break; | |
| } | |
| location ~ /immich/_app/immutable/chunks/fetch-client\\. { | |
| sub_filter_types *; | |
| sub_filter 'baseUrl:"/api' 'baseUrl:"/immich/api'; | |
| proxy_pass http://10.8.1.1:2283; | |
| rewrite /immich/(.*) /$1 break; | |
| } | |
| location ~ /immich/_app/immutable/chunks/api\\. { | |
| proxy_pass http://10.8.1.1:2283; | |
| rewrite /immich/(.*) /$1 break; | |
| sub_filter_types *; | |
| sub_filter '="/api"' '="/immich/api"'; | |
| sub_filter 'basePath:"/api"' 'basePath:"/immich/api"'; | |
| } | |
| location ~ /immich/api/socket.io { | |
| proxy_pass http://10.8.1.1:2283; | |
| rewrite /immich/(.*) /$1 break; | |
| proxy_cache off; | |
| proxy_set_header Accept-Encoding $http_accept_encoding; | |
| proxy_set_header Connection "upgrade"; | |
| proxy_set_header Upgrade websocket; | |
| } | |
| location ~ /immich/api { | |
| proxy_pass http://10.8.1.1:2283; | |
| rewrite /immich/(.*) /$1 break; | |
| proxy_cache off; | |
| sub_filter_types *; | |
| sub_filter '"redirectUri":"/' '"redirectUri":"/immich/'; | |
| } | |
| } | |
| proxy_pass_request_headers on; | |
| proxy_http_version 1.1; | |
| proxy_set_header Upgrade $http_upgrade; | |
| proxy_set_header Connection $connection_upgrade; | |
| slice 10m; | |
| proxy_cache_key $uri$is_args$args$slice_range; | |
| proxy_cache_lock on; | |
| proxy_cache_lock_timeout 0s; | |
| proxy_cache_lock_age 200s; | |
| proxy_cache_min_uses 1; | |
| proxy_set_header Range $slice_range; | |
| 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_set_header X-Forwarded-Host $host; | |
| proxy_set_header X-Forwarded-Server $host; | |
| proxy_cache_use_stale error timeout invalid_header updating | |
| http_500 http_502 http_503 http_504; | |
| proxy_redirect off; | |
| } | |
| } | 
Hello,
I created a nginx ingress based on above config. I'm on 1.143.1. All seems to work :-)
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  annotations:
    nginx.ingress.kubernetes.io/backend-protocol: HTTP
    nginx.ingress.kubernetes.io/client-max-body-size: 8192m
    nginx.ingress.kubernetes.io/configuration-snippet: |
      proxy_set_header Accept-Encoding "";
      sub_filter_once off;
      sub_filter_types *;
      sub_filter ' href="/' ' href="/immich/';
      sub_filter ' src="/' ' src="/immich/';
      sub_filter ' action="/' ' action="/immich/';
      sub_filter 'import("/_app' 'import("/immich/_app';
      sub_filter '"/api/' '"/immich/api/';
      # the following breaks websocket
      #sub_filter '="/' '="/immich/';
      # therefore:
      sub_filter '="/admin' '="/immich/admin';
      sub_filter '="/albums' '="/immich/albums';
      sub_filter '="/libraries' '="/immich/libraries';
      sub_filter '="/archive' '="/immich/archive';
      sub_filter '="/favorites' '="/immich/favorites';
      sub_filter '="/people' '="/immich/people';
      sub_filter '="/places' '="/immich/places';
      sub_filter '="/photos' '="/immich/photos';
      sub_filter '="/explore' '="/immich/explore';
      sub_filter '="/share' '="/immich/share';
      sub_filter '="/sharing' '="/immich/sharing';
      sub_filter '="/shared-links' '="/immich/shared-links';
      sub_filter '="/search' '="/immich/search';
      sub_filter '="/map' '="/immich/map';
      sub_filter '="/user-settings' '="/immich/user-settings';
      sub_filter '="/memory' '="/immich/memory';
      sub_filter '="/trash' '="/immich/trash';
      sub_filter '="/partners' '="/immich/partners';
      sub_filter '="/buy' '="/immich/buy';
      sub_filter '="/auth' '="/immich/auth';
      sub_filter '="/utilities' '="/immich/utilities';
      sub_filter '="/folders' '="/immich/folders';
      sub_filter '="/tags' '="/immich/tags';
      sub_filter '="/locked' '="/immich/locked';
      sub_filter 'basePath:"/api"' 'basePath:"/immich/api"';
      sub_filter 'base: ""' 'base: "/immich"';
      sub_filter 'baseUrl:"/api' 'baseUrl:"/immich/api';
      sub_filter '"redirectUri":"/' '"redirectUri":"/immich/';
      sub_filter 'service-worker.js' 'immich/service-worker.js';
      sub_filter 'light_skeleton.png' 'immich/light_skeleton.png';
      sub_filter "startsWith(`/_app/immutable`)" "startsWith(`/iimmich/_app/immutable`)";
      sub_filter '"_app/immutable' '"immich/_app/immutable';
      sub_filter '"/_app/immutable' '"/immich/_app/immutable';
      sub_filter 'url(/_app/immutable' 'url(/immich/_app/immutable';
      sub_filter '"href","/albums/"' '"href","/immich/albums/"'; # error?
    nginx.ingress.kubernetes.io/proxy-body-size: 8192m
    nginx.ingress.kubernetes.io/proxy-connect-timeout: "3600"
    nginx.ingress.kubernetes.io/proxy-max-temp-file-size: "0"
    nginx.ingress.kubernetes.io/proxy-read-timeout: "3600"
    nginx.ingress.kubernetes.io/proxy-send-timeout: "3600"
    nginx.ingress.kubernetes.io/rewrite-target: /$2
    nginx.ingress.kubernetes.io/use-regex: "true"
    nginx.ingress.kubernetes.io/websocket-services: prod-immich-server
  creationTimestamp: "2025-09-07T15:42:58Z"
  generation: 1
  labels:
    kustomize.toolkit.fluxcd.io/name: apps
    kustomize.toolkit.fluxcd.io/namespace: flux-system
  name: prod-immich-ingress
  namespace: immich
  resourceVersion: "165080218"
  uid: 9381b7f3-cdcd-4f8a-8153-7ad539f2e3ba
spec:
  ingressClassName: public
  rules:
  - http:
      paths:
      - backend:
          service:
            name: prod-immich-server
            port:
              number: 2283
        path: /immich(/|$)(.*)
        pathType: Prefix
status:
  loadBalancer:
    ingress:
    - ip: 127.0.0.1
    
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment
  
            
Hello,
Thank you very much for the configuration file; it has been extremely helpful!
However, after updating Immich to version v1.124.0 this morning, I encountered a significant issue. The update caused everything to break, and I received the following error:
After some troubleshooting, I managed to create a configuration file that works for me. Additionally, I included support for large file uploads with the following directive:
Here is my immich.conf
I still have an issue on the administration panel where all links in the menu are rewritten with a second /immich, resulting in the following error:
I can't figure out why this is happening. If anyone has any ideas, I would greatly appreciate your help !
Have a nice day !