Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[HELP] URL rewrite for static files #418

Open
kAleksei opened this issue Dec 7, 2024 · 3 comments
Open

[HELP] URL rewrite for static files #418

kAleksei opened this issue Dec 7, 2024 · 3 comments
Labels
help wanted Extra attention is needed

Comments

@kAleksei
Copy link

kAleksei commented Dec 7, 2024

What happened?
I'm trying to setup path routing to my containers. When I set up Virtual Directory with path to exact container the request is coming there. But if the service running inside container has static files (e.g. css, js, png etc.) I'm receiving 404.
Example:
Container IP: 192.168.0.11:5555
Host: mydomain.com

Virtual Directory setup:
/app/ -> 192.168.0.11:5555
When I'm trying to access mydomain.com/app server respond 200 OK, but the static files are requesting with wrong path: mydomain.com/css/style.css instead of mydomain.com/app/css/style.css (no /app/ prefix)

Describe what have you tried

Describe the networking setup you are using
Here are some example, commonly asked questions from our maintainers:

  • Are you using the docker build of Zoraxy? Yes
  • Your Zoraxy version? [e.g. 3.1.4]
  • Are you using Cloudflare? yes
  • Are your system hosted under a NAT router? No
  • DNS record - Yes

Additional context
image

@kAleksei kAleksei added the help wanted Extra attention is needed label Dec 7, 2024
@tobychui
Copy link
Owner

tobychui commented Dec 7, 2024

@kAleksei That is the expected behavior of virtual directory. Are you trying to achieve something else?

Your expected behavior seems to not requiring a virtual directory. Try remove all virtual directory entries and see if it will works like you expected?

@kAleksei
Copy link
Author

kAleksei commented Dec 7, 2024

@tobychui, I'm trying to achieve that static files will also use virtual directory route.
Expected behavior:
https://mydomain.com/web-check

Static files to be routed for this container: https://mydomain.com/web-check/style.css

I want to archive that multiple containers will be routed using path based routing.

I see that I have "Referrer" header with destination, maybe I can redirect of rewrite the request url with this header?

Let me know if this makes sense for you.

@tobychui
Copy link
Owner

tobychui commented Dec 8, 2024

@kAleksei If that is the case, you will need to add the sub-path (e.g. /web-check) into your virtual directory path as well. For example

// Proxy Rule, assume your server is at 192.168.1.100. This will handles all the traffic excepts the vdir listed below
mydomain.com --> 192.168.1.100:5555

//Virtual directory, assuming your static file server at 192.168.1.101 and 102
mydomain.com/web-check --> 192.168.1.101:5555/web-check 
mydomain.com/other-static --> 192.168.1.102:5556/other-static

As it is a virtual directory, Zoraxy will rewrite the upstream path for you from the Vdir path to upstream path (aka if you do not add the sub-directory in upstream path, Zoraxy will use the root path "/" as your directory). We actually copied this logic from Apache, so it might not be 100% matching of what Nginx offer. You might need some time to get used to it if you are new to virtual directories.

If this is still not what you want, I guess you might need to explain more on your use case with a diagram of some sort.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants