Hi Rob,

Thanks for you reply, sorry I thought I'd deleted that original post.

As I explain below I'm trying to acheive the following:

myserver.com/app1 proxied to hypnotoad listening on http://*:5000
myserver.com/app2 proxied to hypnotoad listening on http://*:5001
myserver.com/appN proxied to hypnotoad listening on http://*:5..N
Thanks for you reply, sorry I thought I'd deleted that original post.  In 
the example that you kindly provided you're proxying all requests (/) right?

As I mentioned below I'm trying to achieve the following:

myserver.com/app1 dynamic requests proxied to hypnotoad listening on 
http://*:5000, css/js files served directly by Nginx (example path 
app1/public/js/script.js)
myserver.com/app2 dynamic requests proxied to hypnotoad listening on 
http://*:5001, css/js files served directly by Nginx (example path 
app2/public/js/script.js)
myserver.com/appN dynamic requests proxied to hypnotoad listening on 
http://*:5..N, css/js files served directly by Nginx (example path 
app3/public/js/script.js)

I'm adding location directives to my Nginx conf as shown in my second post 
(below) but I've seen a lot of posts about serving the static files for 
each app (js/css) directly from Nginx - although all the examples I’ve seen 
are only based around a single app rather than app1, app2 etc within the 
same server block, I hope that makes sense.

Am I going about this the right way?  If so can I get Nginx to to serve the 
public content for each app directly. 

Thanks again for your help.

On Tuesday, 14 February 2017 20:31:53 UTC, Rob Willett wrote:
>
> See my previous reply to you on this. The config files is just pulled from 
> a production server so we know it works :)
>
> Rob
>
> On Tue, Feb 14, 2017 at 8:13 PM, StarX <mje...@me.com <javascript:>> 
> wrote:
>
>> Hi,
>>
>> I know this has been asked many times and there are various posts 
>> addressing this but I'm struggling to find a concrete example, maybe my 
>> approach is wrong but I'd appreciate some help.
>>
>> So, I have a number of mojo applications, say app1, app2, appN, they all 
>> work great when I spin them up with hypnotoad on their own ports, app1 runs 
>> on 5000, app2 on 5001, appN 5..N.  Can I put all these separate apps behind 
>> Nginx and have Nginx serve the js/css content from the public folder for 
>> each app on a single vhost? I have spent days trying to work this out so I 
>> may be on completely the wrong track.  
>>
>> Here is my Nginx conf on my dev box for app1 and app2.  I can't seem to 
>> get Nginx to serve the static content from the public directory for each 
>> app, it only works if I proxy all requests.  I know this is more of a Nginx 
>> question than Mojo specific but can anyone help please?  What is the 
>> recommended way to do this?
>>
>> server {
>>         listen 80 default_server;
>>         listen [::]:80 default_server;
>>      
>>         # Root for stuff like default index.html
>>         root /var/www/html;
>>
>>       #  location ~* /(images|css|js|files)/ {
>>       #     root /home/username/app1/public/;
>>       #    expires 7d;
>>       #  }
>>
>>         location /app1 {
>>            proxy_pass http://127.0.0.1:5000;
>>            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_set_header X-Forwarded-Host $host:$server_port;
>>        }
>>
>>         location /app2 {
>>            proxy_pass http://127.0.0.1:5001;
>>            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_set_header X-Forwarded-Host $host:$server_port;
>>        }
>>
>>          location /appN {...}
>> }
>>
>> I've also looked at Toadfarm to combine my apps into one but I'm 
>> concerned about scalability, doesn't Toadfarm check each route until it 
>> finds a match?  If I have 15 mojo apps running how is this going to impact 
>> on performance?
>>
>> Thanks
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Mojolicious" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to mojolicious...@googlegroups.com <javascript:>.
>> To post to this group, send email to mojol...@googlegroups.com 
>> <javascript:>.
>> Visit this group at https://groups.google.com/group/mojolicious.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Mojolicious" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to mojolicious+unsubscr...@googlegroups.com.
To post to this group, send email to mojolicious@googlegroups.com.
Visit this group at https://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.

Reply via email to