I have modified existing Apache virtual servers so that they listen to port 8080 instead of 80.

Then I have installed NGINX to receive connections to port 80 and defined one server block for each Apache virtual server with proxy_pass set to the correponding Apache virtual server.

This allows me to use all the existing CGI applications.

I have then created a server block for the new api.example.com with proxy_pass set to localhost:3000:

server { listen 80; listen [::]:80; server_name api.example.com; location / { proxy_pass http://localhost:3000; proxy_redirect off; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; #try_files $uri $uri/ =404; } }
Then I have created two Mojolicious apps, to be mounted via Toadfarm:

#!/usr/bin/perl use Toadfarm -init; mount "/path/to/api01.pl" => { "X-Request-Base" => "http://api.example.com/api01" }; mount "/path/to/api02.pl" => { "X-Request-Base" => "http://api.example.com/api02" }; start ["http://*:3000"], workers => 8;
And I've created the files /path/to/api01.pl:

use Mojolicious::Lite; get '/' => {text => 'Hello! api01 here'}; app->start;
and /path/to/api02.pl:

use Mojolicious::Lite; get '/' => {text => 'Hello! api02 here'}; app->start;
I can then start the script:

$ ./api_start.pl start [2019-02-08 17:17:49.47784] [63828] [info] Mounting api01 with conditi +ons [2019-02-08 17:17:49.48110] [63828] [info] Mounting api02 with conditi +ons * Starting the process api_start_pl ...done. (already running with pid=63819)
But from browser api.example.com/api01 and api.example.com/api02 give me a "Raptor not found Mojolicios message".

Any suggestion? Thanks.

2019-02-10 Athanasius changed <pre> to <code> tags


In reply to Re: Mojolicious to serve more openAPIs by Anonymous Monk
in thread Mojolicious to serve more openAPIs by Anonymous Monk

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



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.