could not add path via nginx reverse proxy
smilence86 opened this issue · comments
I don't want to use subdomain to serve it, instead add a custom path into url, such as https://example.com/share.
my nginx config is looks like:
location /share/ {
proxy_read_timeout 60m;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-Proto https;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Real-IP $remote_addr;
proxy_pass http://127.0.0.1:8000/;
}
location /_h5ai/ {
proxy_pass http://127.0.0.1:8000/h5ai;
}
It won't show files in browser, what am I wrong or something missing? please help me.
Hi,
I think you can get that by the following configs.
location /share {
return 301 $scheme://$host/dokuwiki/;
}
location ^~ /share/ {
proxy_read_timeout 60m;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-Proto https;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Real-IP $remote_addr;
proxy_pass $http://127.0.0.1:8000;
rewrite /share(.*) $1 break;
}
You don't need to add location /_h5ai/
in your reverse proxy configure because as we know the docker app creates a web server independently.
Not tested, sorry, but it is worth trying.
Seems not work, some static files are 404 error:
Something Need explain further, The port 8000 is h5ai listening by docker container, There are few other services running behind nginx as well:
location /speedtest/ {
auth_basic "input password";
auth_basic_user_file /etc/nginx/conf.d/pwd.db;
proxy_read_timeout 60m;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-Proto https;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Connection "upgrade";
proxy_redirect off;
proxy_pass http://127.0.0.1:8686/;
}
location /adg/ {
proxy_read_timeout 60m;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-Proto https;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Connection "upgrade";
proxy_redirect off;
proxy_pass http://127.0.0.1:3000/;
}
location /wireguard/ {
proxy_read_timeout 60m;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-Proto https;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Connection "upgrade";
proxy_redirect off;
proxy_pass http://127.0.0.1:51821/;
}
I want to use one domain cert to manager all services by tls.
Ah, you were right, seems we need to specify a location for _h5ai
directory.
Then how about adding this one?
location ^~ /share/_h5ai {
proxy_read_timeout 60m;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-Proto https;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Real-IP $remote_addr;
proxy_pass $http://127.0.0.1:8000;
rewrite /share(.*) $1 break;
}
Maybe rewrite
is not needed.. But don't know.
If you can't get even with the new configuration, I will test it on my side soon.
Also 404
location ^~ /share/ {
proxy_read_timeout 60m;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-Proto https;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Real-IP $remote_addr;
proxy_pass http://127.0.0.1:8000/;
}
location ^~ /share/_h5ai {
proxy_read_timeout 60m;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-Proto https;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Real-IP $remote_addr;
proxy_pass http://127.0.0.1:8000;
rewrite /share(.*) $1 break;
}
Sorry, for the last try, how about this one?
location ^~ /share/_h5ai {
proxy_read_timeout 60m;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-Proto https;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Real-IP $remote_addr;
proxy_pass http://127.0.0.1:8000/_h5ai;
rewrite /share(.*) $1 break;
}
I appended /_h5ai
to the proxy_pass
property.
Will test on my side 😅
Will test on my side sweat_smile
Thanks for your help.
Hello, any updates for this?
Hi,
I tried but couldn't succeed yet. I think it is very difficult because each URL indicates each file, and this is managed by a PHP index file under /_h5ai
directory.
Sorry, 😅
Anyone who can know how to this configure?
Okay, Thanks, I'll use subdomain first before that could work.