Doug,

Post this to: https://forum.nginx.org/

David Ringsmuth

From: Doug Hall via 4D_Tech
Sent: Friday, September 29, 2017 12:28 PM
To: 4D iNug Technical
Cc: Doug Hall
Subject: Re: NGINX Config

I am having some problems with my Nginx reverse proxy. I'm running 4Dv15,
and Active4D 6.4r3, using the 4D server shell. I have successfully
configured two web roots in Active4D, which run on the same 4D Web Client,
on port 8010. I have two different host names which are pointed to the same
IP address. I'll call them name1.domain.com:8010 and name2.domain.com:8010.
These successfully resolve to the appropriate web root within Active4D,
when I put those two urls in my web browser.

I set up my proxy in nginx two different ways, and neither of them
consistently resolve to the right website:

1: I setup one upstream server and accessed it through proxy_pass from both
server definitions:

upstream 4d_webclient{
    server 127.0.0.1:8010;
}

server {
    listen 80;
    server_name name1.domain.com;

    location / {
       root   /location_1
       proxy_pass http://4d_webclient;
       ...
    }
}

server {
    listen 80;
    server_name name2.domain.com;

    location / {
       root /location_2
       proxy_pass http://4d_webclient;
       ...
    }
}

Please note that I'm just trying to get the reverse proxy to work. Once I
do that, I'll add SSL requirements, and all the necessary rewrites to make
sure people are redirected to our secured interface.

The second way I did it was to create a different upstream for each
website, using the DNS names for each, and then calling the appropriate
upstream proxy from each server definition:

upstream name1_server{
    server name1.domain.com:8010;
}

upstream name2_server{
   server name2.domain.com:8010;
}

... (the same as above, except replacing 4d_webclient with name1/2_server
at proxy_pass)

Both ways gave the same results. After restarting my Web Client and nginx
(just to make sure I start from a clean slate), both name1.domain.com and
name2.domain.com resolve to the name1:domain.com:8010 website. However, if
I go to name2.domain.com:8010, then both name1.domain.com and
name2.domain.com will resolve to that website. Going to
name1.domain.com:8010 then causes both portless addresses to resolve there,
until I visit name2.domain.com:8010 directly again.

Obviously, I don't understand the relationship between how nginx deals with
upstream declarations and how that passes along to Active4D. Any help would
be appreciated.

Doug

On Fri, Oct 24, 2014 at 1:31 PM, Balinder Walia <balinder.wa...@gmail.com>
wrote:

> and then test by sending 100s of requests at the same time using Apache
> benchmark:
>
> Example type:
>
> $ ab -n 1000 -c 5 http://www.domain.com
>
> from Mac/Linux Terminal
>
> Balinder
>
> On 24 October 2014 19:26, Balinder Walia <balinder.wa...@gmail.com> wrote:
>
> > Brad,
> >
> > There are many ways to achieve it. Simplest is probably to count no of
> > processes and busyness in 4D and if too busy or near enough to use all
> > memory then get 4D to create 502.html file with appropriate message. Or
> > create if 4D is dead just leave one 502.hm there as a default option.
> >
> >
> > In JSON's script above see
> >
> >          proxy_next_upstream error timeout invalid_header http_500
> > http_502 http_503 http_504;
> >
> > what that means if proxy failed then intercept the error and show default
> > message in 502.htm
> >
> > So you would something like:
> >
> > in the main proxy block then
> >
> > proxy_intercept_errors on;
> > error_page 403 404 502 504 = @fallback;
> > break;
> >
> > and separate block what to do if proxy failed
> >
> > location @ fallback {
> > proxy_set_header X-Real-IP $remote_addr;
> > proxy_set_header Host $host;
> > proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
> >
> > root html;
> > index.hm which can have 502 error message or default message about 4d
> too
> > busy!
> > break;
> > }
> >
> > To be honest in this day and age we should never have a downtime and
> > customer should never see this unavailable error. they won't come back.
> So
> > I appreciate we should have a nice message on fail but setup the system
> so
> > it never fails.
> >
> >
> > On 24 October 2014 18:15, Perkins, Bradley D <bperk...@lanl.gov> wrote:
> >
> >> I'd also like to say thanks for all of these. I still use Apache but
> >> wondered about NGINX.
> >>
> >> >Any suggestions on making the Nginx server a fail-over to a hung 4D
> >> >server?
> >>
> >> Since I'm unfamiliar with NGINX, this may not help at all, but under
> >> Apache I always modify the error files for 502 (or 503?) errors so that
> >> they contain user friendly "site unavailable" messages. Those files get
> >> served when Apache can't reverse proxy to 4D.
> >>
> >> -- Brad
> >>
> >>
> >> **********************************************************************
> >> See how easy it is to extend your 4D solutions to Web and mobile. New
> >> opportunities await you with 4D v14!
> >>
> >> 4D Internet Users Group (4D iNUG)
> >> FAQ:  http://lists.4d.com/faqnug.html
> >> Archive:  http://lists.4d.com/archives.html
> >> Options: https://lists.4d.com/mailman/options/4d_tech
> >> Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
> >> **********************************************************************
> >>
> >
> >
> **********************************************************************
> See how easy it is to extend your 4D solutions to Web and mobile. New
> opportunities await you with 4D v14!
>
> 4D Internet Users Group (4D iNUG)
> FAQ:  http://lists.4d.com/faqnug.html
> Archive:  http://lists.4d.com/archives.html
> Options: https://lists.4d.com/mailman/options/4d_tech
> Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
> **********************************************************************
>
**********************************************************************
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**********************************************************************

**********************************************************************
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**********************************************************************

Reply via email to