Replies: 8 comments
-
Hi @MSWS, I'm not an expert with Nginx either, but I was able to make it work under caddy inside a subdirectory as is your usecase. The following works with caddy: @test host test.mydomain.com
handle @test {
redir /s /s/
rewrite /api* /s{uri}
handle_path /s* {
reverse_proxy chhoto-url-dev:4567
}
} where the service is assumed to be at Edit: Never mind, this will cause some issues if you have other services. I guess I can make small modifications to the js file to make it work. |
Beta Was this translation helpful? Give feedback.
-
I just pushed the commit d278021, which should fix your issue. Can you try it out? Using the It should now just work with
You still need to figure out how to handle the subdirectory properly in Nginx, that's not something I can fix from my side. |
Beta Was this translation helpful? Give feedback.
-
Thanks for the response! I've manually built the code just to double-check, and have cache disabled through Cloudflare. Still running into the 404 code error with the following config: location /s {
return 301 /s/;
}
location /s/ {
include /config/nginx/proxy.conf;
include /config/nginx/resolver.conf;
set $upstream_app chhoto-url;
set $upstream_port 4567;
set $upstream_proto http;
proxy_pass $upstream_proto://$upstream_app:$upstream_port;
proxy_set_header Host $host;
} services:
chhoto-url:
build: .
restart: unless-stopped
container_name: chhoto-url
ports:
- 4567:4567
environment:
# Change if you want to mount the database somewhere else
# In this case, you can get rid of the db volume below
# and instead do a mount manually by specifying the location
- db_url=/data/urls.sqlite
- site_url="https://website.com/s/"
- password=${password} |
Beta Was this translation helpful? Give feedback.
-
Can you try adding |
Beta Was this translation helpful? Give feedback.
-
Doesn't look like that works, it gives me an Nginx 500 Internal Server Error both with I did actually manage to get this working without the dev version with the following nginx config, just need to figure out a small kink on my end. If this is too much of a headache to look further into then no worries as I've got sufficient functionality so far. This config depends on chhoto being hosted on a subdomain, and just proxies all requests beginning with /s to that subdomain, rewritten. # Redirect /s to /s/
location = /s {
return 301 /s/;
}
# Rewrite for /api* requests
location /api {
rewrite ^/api(.*) /s$1 break;
proxy_pass http://chhoto-url:4567; # Reverse proxy
proxy_set_header Host $host; # Important for proxying
proxy_set_header X-Real-IP $remote_addr; # Important for proxying
}
# Catch-all for other paths starting with /s/
location /s/ {
rewrite ^/s/(.*)$ https://dummy.example.com/$1;
proxy_pass http://chhoto-url:4567; # Reverse proxy
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
} |
Beta Was this translation helpful? Give feedback.
-
Good to know that you were able to make it work. Note though that it might cause issues if any other app hosted there uses |
Beta Was this translation helpful? Give feedback.
-
Thanks for the resources. FWIW the dev version seems to put quotes around the path now when I try copying from the UI. eg: it copies |
Beta Was this translation helpful? Give feedback.
-
Oh, I must've goofed up somewhere while trying to get rid of double slashes. I'll take a look. Thanks for letting me know. |
Beta Was this translation helpful? Give feedback.
-
Is your feature request related to a problem? Please describe.
I am attempting to host this behind an Nginx server alongside a main website (eg: https://website.com/s would take me to the dashboard, and https://website.com/s/short1 would be a possible short URL).
Setting a straightforward redirect from the /s path to the docker container leads to a 404 page error.
Describe the solution you'd like
Ideally setting the
site-url
within the environment vars should make it automagically work with the appropriate Nginx config.Describe alternatives you've considered
I'm fairly inexperienced with Nginx, however I have tried modifying the URL path on its end, and I still came up with a 404 error. Ideally I should be able to either do this through the app's settings, or through Nginx.
Additional context
This is my current nginx config which results in a 404 error.
Beta Was this translation helpful? Give feedback.
All reactions