1

Let me start from middle. I have been play around for a long time with these three part:

  1. nginx which handles the path
  2. Fastapi server
  3. sqlAdmin

The url https://example.com/gem/admin must be passed to sqlAdmin but there is this agonizing contrast. If nginx configs like:

location /gem/admin/ {
    proxy_pass http://172.18.0.18:80/;

and sqlAdmin like:

admin = Admin(
    application, 
    engine, 
    authentication_backend=authentication_backend,
    base_url="/admin",
    title="Gem Admin Panel"
)

request will not be passed to sqlAdmin and be served by FastApi like

{"detail":"Not Found"}

If I remove base_url then the styles url would be wrong like (missing admin):

https://example.com/gem/statics/css/fontawesome.min.css

If I remove trailing slash from nginx location and proxypass then it will add another admin to url resulting to 404 error.

it is frustrainting really. Please help me out.

3
  • 1
    Why base_url="/admin" but not base_url="/gem/admin"? Commented Nov 16 at 15:10
  • Instead of blindly guessing the values for the location directive prefix and the proxy_pass directive upstream URI part, wouldn't it be better to read the documentation? If you don't understand the difference between the proxy_pass http://172.18.0.18 and proxy_pass http://172.18.0.18/ directives and the nginx documentation is too complicated for you, you can read this answer, where I quote the documentation excerpts regarding the rules that proxy_pass follows to pass the request URI to the backend. Commented Nov 16 at 15:29
  • I don't fully understand where the /gem URI prefix comes from, but according to the configuration you've shown, you probably need to define base_url as /gem/admin and use the following location block: location /gem/admin/ { proxy_pass http://172.18.0.18; } (Without the trailing slash! You don't need the /gem/admin request URI prefix to be stripped from the URI that goes to the backend! The port 80 is the default port for the plain HTTP protocol and can be omitted.) Commented Nov 16 at 15:30

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.