Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

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.


In reply to Re: Mojolicious-Hypnotoad-Nginx - rendering images by alexander_lunev
in thread Mojolicious-Hypnotoad-Nginx - rendering images by pdkakoba

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (7)
As of 2024-04-19 15:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found