-
-
Save aveexy/4b2b22b2198636b0a91c7c142ec11b37 to your computer and use it in GitHub Desktop.
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; | |
} | |
} |
probably incompatibility with new immich version, have not updated yet, will look into it
now compatible with immich v1.97.0
broken again for v1.98 :(
ue@https://xxx/immich/_app/immutable/chunks/fetch-client.QHRKs229.js:1:2907
ie@https://xxx/immich/_app/immutable/chunks/fetch-client.QHRKs229.js:1:2831
can you provide more details? when does this error occur?
v1.98.2 works mostly fine for me. only thing that does not work is the websocket connection, upstream did something that prevents the connection, and it's pretty annoying to debug :(
can you provide more details? when does this error occur?
v1.98.2 works mostly fine for me. only thing that does not work is the websocket connection, upstream did something that prevents the connection, and it's pretty annoying to debug :(
lol sorry - I left it out since it's the exact same as aveexy, as soon as I load up the app
Strange though, I'm on 1.98.0 since that's the latest on docker and getting the error
i've just updated the gist. added some fixes for the websocket connection. nginx completely loses it as soon as encoding headers are present and drops the connection upgrade headers needed for websocket protocol switch.
it might be necessary to delete all the cached files in /var/cache/nginx/immich_revprox
Does anyone have a config for Apache?
Edit: Never mind, switched to using a subdomain.
thank you, great!!
there is my config, proxy pass to 127.0.0.1:2283, and modified something code because the error, I just delete some code nginx -t
show to me, but I don't understand them. the config work perfectly now.
@aveexy thank you again, and your nginx skill is so excellent, how do you learn it?
location /immich {
proxy_pass http://127.0.0.1:2283;
rewrite /immich/(.*) /$1 break;
proxy_set_header Accept-Encoding "gzip";
gunzip on;
proxy_pass_request_headers on;
proxy_buffering on;
proxy_cache_valid 200 206 1d;
sub_filter_once off;
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://127.0.0.1:2283;
rewrite /immich/(.*) /$1 break;
}
location ~ /immich/_app/immutable/chunks/(index|app)\\. {
sub_filter_types *;
sub_filter '"/' '"/immich/';
proxy_pass http://127.0.0.1:2283;
rewrite /immich/(.*) /$1 break;
}
location ~ /immich/_app/immutable/chunks/constants {
sub_filter_types *;
sub_filter '="/' '="/immich/';
proxy_pass http://127.0.0.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://127.0.0.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://127.0.0.1:2283;
rewrite /immich/(.*) /$1 break;
}
location ~ /immich/_app/immutable/chunks/api\\. {
proxy_pass http://127.0.0.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://127.0.0.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://127.0.0.1:2283;
rewrite /immich/(.*) /$1 break;
proxy_cache off;
sub_filter_types *;
sub_filter '"redirectUri":"/' '"redirectUri":"/immich/';
}
}
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:
Error: Error: 404
at Object.ht [as ok] (https://mydomain.com/immich/_app/immutable/chunks/fetch-client.DqMPutSq.js:1:7918)
at async Promise.all (index 0)
at async n (https://mydomain.com/immich/_app/immutable/chunks/server-config.store.DzAD3Dok.js:1:530)
at async o (https://mydomain.com/immich/_app/immutable/chunks/server.B9uUtD4f.js:1:224)
at async ra (https://mydomain.com/immich/_app/immutable/nodes/0.CItVphcP.js:1:2484)
at async Wt (https://mydomain.com/immich/_app/immutable/chunks/entry.CGh5KwEn.js:1:17711)
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:
client_max_body_size 50000M;
Here is my immich.conf
location /api/ {
return 301 /immich$request_uri;
}
location /immich {
proxy_pass http://127.0.0.1:2283;
rewrite /immich/(.*) /$1 break;
proxy_set_header Host $host;
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 Accept-Encoding "gzip";
gunzip on;
proxy_pass_request_headers on;
proxy_buffering on;
proxy_cache_valid 200 206 1d;
sub_filter_once off;
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"';
sub_filter '"/api/' '"/immich/api/';
# Handle the root path assets
location /immich/ {
proxy_pass http://127.0.0.1:2283/;
proxy_set_header Host $host;
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;
}
# Handle JavaScript files
location ~ \.js$ {
sub_filter_types application/javascript;
sub_filter '"/api/' '"/immich/api/';
sub_filter_once off;
proxy_pass http://127.0.0.1:2283;
rewrite /immich/(.*) /$1 break;
}
location ~ /immich/_app/immutable/chunks/fetch-client\\. {
sub_filter_types application/javascript;
sub_filter 'baseUrl:"/api' 'baseUrl:"/immich/api';
sub_filter '"/api/' '"/immich/api/';
sub_filter_once off;
proxy_pass http://127.0.0.1:2283;
rewrite /immich/(.*) /$1 break;
}
# Handle WebSocket connections
location ~ /immich/api/socket.io {
proxy_pass http://127.0.0.1:2283;
rewrite /immich/(.*) /$1 break;
proxy_cache off;
proxy_buffering off;
proxy_set_header Accept-Encoding $http_accept_encoding;
proxy_set_header Connection "upgrade";
proxy_set_header Upgrade websocket;
proxy_set_header Host $host;
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;
}
# Handle API requests
location ~ /immich/api {
proxy_pass http://127.0.0.1:2283;
rewrite /immich/(.*) /$1 break;
proxy_cache off;
proxy_buffering off;
proxy_set_header Host $host;
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;
sub_filter_types *;
sub_filter '"redirectUri":"/' '"redirectUri":"/immich/';
}
}
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:
Not found: /immich/immich/admin/library-management - 404
undefined
I can't figure out why this is happening. If anyone has any ideas, I would greatly appreciate your help !
Have a nice day !
I am getting these errors after trying this config:
It's a popup in the middle of immich page as soon as i load it.
(it's working fine in subdomain at the same time)