[Gambas-user] Configure real httpd for gb.web.form

Tobias Boege taboege at ...626...
Mon Mar 13 23:09:40 CET 2017


On Thu, 16 Feb 2017, Benoît Minisini wrote:
> Le 16/02/2017 à 03:20, Tobias Boege a écrit :
> > Hi list,
> >
> > has anyone here ever set up a real HTTP server for running gb.web.form
> > applications? I've decided to use nginx and setting up https there was
> > easy enough (https being the the reason why I can't use gb.httpd).
> > Normal Gambas CGI, i.e. a Gambas script with gb.web, also works fine.
> >
> > But I have no idea about gb.web.form.
> 
> Projects using gb.web.form are CGI scripts too, no difference.
> 
> > I read around in the gb.httpd
> > source code and kind of get its control flow but I'm none the wiser
> > about how to set up an external HTTP server to work with this component.
> > In particular I would run the .gambas executable archive on every request,
> > which, I presume, involves rewriting the request URL, i.e.
> >
> >   /my/project.gambas/x
> >
> > should be redirected to
> >
> >   /my/project.gambas
> >
> > while setting Request.Path to "/x".
> >
> > I'm not sure if any other information about my setup is useful here.
> > I think I succeeded in redirecting all requests to my program and by
> > setting PATH_INFO from the original request URL, I get a meaningful
> > Request.Path in Gambas.  The result being that the skeleton HTML of my
> > page is shown but it's not responsive at all (and it appears to be the
> > wrong page, i.e. the wrong Webform.Startup, indicating that probably
> > Session management doesn't work). It also seems like the browser is not
> > able to communicate with gb.web.form.
> >
> > Instead of trying to debug my setup which looks completely wrong, my
> > question would be if someone has a working configuration for this type
> > of project for any HTTP server (that isn't gb.httpd) -- in the hope
> > that I can go from there to nginx.
> >
> > Regards,
> > Tobi
> >
> 
> Example with the configuration file of lighttpd:
> 
> ...
> # This tells that all and executable files are cgi scripts,
> # and just them
> cgi.execute-x-only = "enable"
> cgi.assign = ( "" => "" )
> ...
> # This tell that the "/manager" URL is associated with the CGI script
> alias.url = ( "/manager" => "/path/to/MyCgiScript.gambas" )
> 

I've had more success with these 3 lines in lighttpd than in nginx
(I guess because lighttpd sets CGI variables differently), but I'm
not able to run *my* project.

I'm sure there are several things wrong with it. For one I'm unable to
compile it completely (it crashes the compiler with a segfault, but only
a minor thing in gbc_help.c, IIRC) -- now that I think about it, I'm
not even sure if all compiled object files have the same version when
I run the project... And I also mess a lot with Request.Path in my
WebForm's HandleRequest() hook. It works with gb.httpd though, so it
can't be that terrible.

Sadly I'm with my back against a wall concerning time. So, for now my
solution is the following:

  1. Patch gb.httpd to recognise the GB_HTTPD_HOSTNAME environment
     variable, which lets you specify the host to bind to (patch attached).
  2. Run my project under gb.httpd (gbx3 -H), bind to an unused port,
     e.g. GB_HTTPD_PORT=8080, and to GB_HTTPD_HOSTNAME=127.0.0.1.
     This ensures that nobody not on localhost is able to accidentally
     connect to the gb.httpd server directly.
  3. Run nginx as a proxy HTTPS server for the local gb.httpd one. The
     configuration for that is really simple:

       server {
         listen              443 ssl;
         server_name         ...;
         ssl_certificate     ...;
         ssl_certificate_key ...;

         location / {
           proxy_pass http://127.0.0.1:8080;
         }
       }

This accomplishes all I wanted, although I'm not too comfortable running
gb.httpd instead of a properly maintained httpd. I'll report back (possibly
in a new thread) once I sort this out.

Regards,
Tobi

-- 
"There's an old saying: Don't change anything... ever!" -- Mr. Monk
-------------- next part --------------
A non-text attachment was scrubbed...
Name: add-GB_HTTPD_HOSTNAME-to-gb.httpd.patch
Type: text/x-diff
Size: 448 bytes
Desc: not available
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20170313/67e219c5/attachment.patch>


More information about the User mailing list