Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re^3: Mojolicious-Hypnotoad-Nginx - rendering images

by pdkakoba (Novice)
on Apr 19, 2021 at 10:30 UTC ( [id://11131465]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Mojolicious-Hypnotoad-Nginx - rendering images
in thread Mojolicious-Hypnotoad-Nginx - rendering images

Success was found with an Apache2 setup with mod_proxy, mod_proxy_http, mod_headers and inspired from these two presentations: https://github.com/mojolicious/mojo/wiki/Apache-deployment
https://stackoverflow.com/questions/23571608/configure-urls-with-prefix-in-mojolicious-behind-reverse-proxy-proxypass

1) The image reference remained as:  <img src="/tree.png" alt="tree">
2) using this configuration in Apache2 (version:2.4.38):

ServerName example.com <Proxy *> Require all granted </Proxy> ProxyPass /static ! ProxyPass /favicon.ico ! ProxyRequests Off ProxyPreserveHost On ProxyPass /echo ws://localhost:8080/echo ProxyPass / http://localhost:8080/ keepalive=On ProxyPassReverse / http://localhost:8080/ RequestHeader unset X-Forwarded-Host RequestHeader set X-Forwarded-Proto "http"

Result renders both the tree image and the custom favicon on both pages.
Does that above give insight into seeking a Nginx solution?

The above Apache2 solution gave hint to a successful Nginx solution as follows:
upstream backendurl { server 127.0.0.1:8080 fail_timeout=0; } server { listen 443 ssl; listen [::]:443 ssl; server_name myexample.com www.myexample.com; access_log /var/log/nginx/access.log; error_log /var/log/nginx/error.log info; root /home/sammy/simple_image/public; location / { try_files $uri @proxy; access_log off; expires max; add_header 'Access-Control-Allow-Origin' 'https://myexample.com'; } location /static { try_files $uri @proxy; access_log off; expires max; add_header 'Access-Control-Allow-Origin' 'https://myexample.com'; } location @proxy { proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; proxy_set_header Host $host; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; proxy_pass http://backendurl; } ssl_prefer_server_ciphers on; #add all the necessary ssl files, (eg .crt and key files) and li +nks here }
Postscript 22-May-2021: The problem appeared to be with the install of iRedmail (a popular mailserver setup) on the same server. Recently the application was revised to 1.4.0 version. After rebuilding the server with the updated iRedmail app, the published Mojolicious deployment code worked successfully.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (5)
As of 2024-03-28 18:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found