Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: Mojolicious-Hypnotoad-Nginx - rendering images

by alexander_lunev (Pilgrim)
on Apr 15, 2021 at 17:42 UTC ( [id://11131340]=note: print w/replies, xml ) Need Help??


in reply to Mojolicious-Hypnotoad-Nginx - rendering images

I will not lecture you about 'asking questions: the right way', but if you really want an answer - send more information, please. Now to the business. One of my systems have exactly such setup - hypnotoad serving application on localhost:3000, nginx doing reverse proxy. I don't see where is you're problem could be, I will post my configs so you can find the answer yourself just by comparison of yours and mine configs.

Application is located in /usr/local/x/ports/portmgr, so there is /usr/local/x/ports/portmgr/public dir for static files. There is also /usr/local/www/mgmt dir for other static files.

Nginx:

server { listen 80; server_name mgmt.site.local; location / { try_files $uri @proxy; root /usr/local/www/mgmt; add_header 'Access-Control-Allow-Origin' 'http://some.site.local'; } location @proxy { auth_basic "RTK MGMT Site"; auth_basic_user_file /usr/local/x/snmp/passwd; proxy_pass http://localhost:3000; proxy_set_header Host $host; proxy_set_header X-Forwarded-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; } }

With such config when someone request http://mgmt.site.local/image.png, 1) nginx search /usr/local/www/mgmt for image.png, if not found, 2) request goes to http://localhost:3000, 3) hypnotoad look in /usr/local/x/ports/portmgr/public (and other static paths, which you can add in script) for static file image.png, if it's not found, 4) hypnotoad search routes for /image.png, if no route found, then 404 error displayed.

I would also suggest you to point your nginx root to your application public dir, so static files could be served by nginx, not Mojolicious, thus they will be served much faster.

UPDATE: sorry, i've checked (and corrected post) - hypnotoad first look for static file, then look in routes.

Replies are listed 'Best First'.
Re^2: Mojolicious-Hypnotoad-Nginx - rendering images
by perlfan (Vicar) on Apr 15, 2021 at 17:59 UTC
    > I will not lecture you about 'asking questions: the right way'

    Say what you mean.

      I'm talking about the infamous document born of bygone era of Usenet (but I got to know it from the FIDOnet, already translated to my native language).

      TA-DA! - How To Ask Questions The Smart Way

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11131340]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (2)
As of 2024-04-25 20:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found