Configure real httpd for gb.web.form

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Configure real httpd for gb.web.form

Tobias Boege-2
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. 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

--
"There's an old saying: Don't change anything... ever!" -- Mr. Monk

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Gambas-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gambas-user
Reply | Threaded
Open this post in threaded view
|

Re: Configure real httpd for gb.web.form

Benoît Minisini
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" )

Regards,

--
Benoît Minisini

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Gambas-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gambas-user
Reply | Threaded
Open this post in threaded view
|

Re: Configure real httpd for gb.web.form

Benoît Minisini
Le 16/02/2017 à 03:33, Benoît Minisini a écrit :
>
> Example with the configuration file of lighttpd:
>
> ...
> # This tells that all and executable files are cgi scripts,

---> This tells that all executable files are cgi scripts,

--
Benoît Minisini

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Gambas-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gambas-user
Reply | Threaded
Open this post in threaded view
|

Re: Configure real httpd for gb.web.form

Tobias Boege-2
In reply to this post by Benoît Minisini
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 <a href="http://127.0.0.1:8080;">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

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Gambas-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gambas-user

add-GB_HTTPD_HOSTNAME-to-gb.httpd.patch (463 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Configure real httpd for gb.web.form

PICCORO McKAY Lenz
2017-03-13 18:09 GMT-04:00 Tobias Boege <[hidden email]>:

> On Thu, 16 Feb 2017, Benoît Minisini wrote:
> > > 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.
>

after too much reading and testing, proyects with or without web.form
compiled produce a gambas exceutable file

Nginx doesn't have native CGI support (it supports fastCGI instead). The
typical solution for this is to run your gambas script as a fastCGI process
and edit the nginx config file to re-direct requests to the fastCGI
process. This is quite a complex solution if all you want to do is run a
CGI script.

a trick lke the gambasforge does, rename the gambas executable file and
added a extension, and follow the same recipe as do with perl.. as i said
this are quite complicated process due there's no wrapper for gambas cgi
scripts.. so must be a socket that ngynx can listen to manage the
cgi/gambas program as real cgi

> >
> > > 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 <a href="http://127.0.0.1:8080;">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
>
> ------------------------------------------------------------
> ------------------
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> _______________________________________________
> Gambas-user mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/gambas-user
>
>
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Gambas-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gambas-user
Reply | Threaded
Open this post in threaded view
|

Re: Configure real httpd for gb.web.form

Tobias Boege-2
On Mon, 13 Mar 2017, PICCORO McKAY Lenz wrote:

> 2017-03-13 18:09 GMT-04:00 Tobias Boege <[hidden email]>:
>
> > On Thu, 16 Feb 2017, Benoît Minisini wrote:
> > > > 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.
> >
>
> after too much reading and testing, proyects with or without web.form
> compiled produce a gambas exceutable file
>
> Nginx doesn't have native CGI support (it supports fastCGI instead). The
> typical solution for this is to run your gambas script as a fastCGI process
> and edit the nginx config file to re-direct requests to the fastCGI
> process. This is quite a complex solution if all you want to do is run a
> CGI script.
>
> a trick lke the gambasforge does, rename the gambas executable file and
> added a extension, and follow the same recipe as do with perl.. as i said
> this are quite complicated process due there's no wrapper for gambas cgi
> scripts.. so must be a socket that ngynx can listen to manage the
> cgi/gambas program as real cgi
>

As I already said in my first mail (quoted above), I can run Gambas CGI
projects, be it .gbs scripts or .gambas executables (and yes, it goes
through an fcgi wrapper).

What I cannot run is a specific project of mine and that problem seems to
be independent of gb.web.form, as Benoit said, but purely a webserver
configuration issue. It's been 2+ weeks already since I last fiddled around
with it, but I remember noting that the problem was with CGI variables not
being set correctly by my nginx configuration, so that in particular
Request.Path and Application.Root came out mangled after the URL rewriting,
giving all kinds of problems, as you can imagine.

Regards,
Tobi

--
"There's an old saying: Don't change anything... ever!" -- Mr. Monk

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Gambas-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gambas-user