Skip to content

Instantly share code, notes, and snippets.

@aveexy
Last active May 5, 2024 11:26
Show Gist options
  • Save aveexy/4b2b22b2198636b0a91c7c142ec11b37 to your computer and use it in GitHub Desktop.
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
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;
}
}
@sidamos
Copy link

sidamos commented May 5, 2024

Does anyone have a config for Apache?
Edit: Never mind, switched to using a subdomain.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment