Forum > Networking and Web Programming

Anybody used nginx for Windows?

(1/4) > >>

egsuh:
Has anybody used nginx on Windows together with fpweb applications?

What are characteristics and benefits of nginx over IIS?

I have written on TWebModule.kind --- wkPooled and wkOneShot previously.  wkPooled mode causes errors when run in FCGI or HTTPServer applications.  So I separated TDataModule which contains database and queries. In FastCGI or HTTPServer, webmodule is created at every request, but datamodule which contains database is created only once.

Even with this, FastCGI causes server errors.  I could remove occurrences of errors by setting FastCGI's max request number per instance to 20 ~ 25 (I wrote about this in previous threads). 

There have been no problem with HTTPserver yet --- I could access several hundreds of times without restarting HTTPServer application without any error. 

I'm running HTTPServer application as Windows service, and this solves the most serious problem (reconnecting the database every request). But this is little bit limited, as it cannot process other requests like requesting simple HTML file (Yes, I could write the program and specify paths, but it's too complicated).   

I read about nginx today (because Lazarus FCGI application template explains to define port for e.g. nginx, etc.). Is nginx flexible as IIS? Does it support fastCGI mode? I'll google for the data, but hope quick replies from those who have used nginx with fpweb.

Thaddy:
One advantage over IIS is that nginx is cross platform.

egsuh:
I read some materials on the nginx and installed it on my PC. I could see the basic "localhost" page.

Running FastCGI app independently is rather interesting --- hoping that it has the same effect as HTTPServer. But the configuration is too complex for me (not familiar with Linux) now. 

Leledumbo:

--- Quote from: egsuh on October 03, 2021, 11:52:26 am ---What are characteristics and benefits of nginx over IIS?

--- End quote ---
Basically you're not tied to one specific OS so you can develop and deploy on different OSes, just in case you want to deploy on Linux but feeling more comfortable developing on Windows. The configuration can be shared largely, differing only in file paths.

--- Quote from: egsuh on October 03, 2021, 11:52:26 am ---There have been no problem with HTTPserver yet --- I could access several hundreds of times without restarting HTTPServer application without any error. 

--- End quote ---
Despite was designed mainly for testing during development, I do find the same experience: it's the most stable interface out of all 4.

--- Quote from: egsuh on October 03, 2021, 11:52:26 am ---But this is little bit limited, as it cannot process other requests like requesting simple HTML file (Yes, I could write the program and specify paths, but it's too complicated).

--- End quote ---
This can be delegated to nginx, let your HTTP application serves data only, not static files. Real world deployment will consider CDN instead, so you have even less traffic burden.

--- Quote from: egsuh on October 03, 2021, 11:52:26 am ---Is nginx flexible as IIS?

--- End quote ---
No, it's A HELL LOT MORE flexible ;)

--- Quote from: egsuh on October 03, 2021, 11:52:26 am ---Does it support fastCGI mode?

--- End quote ---
Both FastCGI and reverse proxy are supported built-in, CGI (and obviously Apache module) do(es)n't. I use reverse proxy, though, not FastCGI due to stability reason above, but your mileage may vary.

egsuh:
@ Leledummbo,

Thank you for your kind replies. I tried some, and now I can run FCGI through nginx.

First, I run my fcgi program as stand-alone (I didn't know this works. What's difference from HTTPserver?)

Following is the whole codes I wrote.  The default ACTION is Hello, which says something like 'Hello,World'.

I added another action "Morning", which says "Good Morning".



--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---program fcgi_1; {$mode objfpc}{$H+} uses  fpFCGI, uwm1; begin  Application.Title:='fcgiproject1';  { Uncomment the port setting here if you want to run the     FastCGI application stand-alone (e.g. for NGINX) }  Application.Port:=2015; // For example  Application.LegacyRouting := true;  Application.Initialize;  Application.Run;end.  unit uwm1; {$mode objfpc}{$H+} interface uses  SysUtils, Classes, httpdefs, fpHTTP, fpWeb; type   { Twm1 }   Twm1 = class(TFPWebModule)     procedure MorningRequest(Sender: TObject; ARequest: TRequest;        AResponse: TResponse; var Handled: Boolean);  private   public   end; var  wm1: Twm1; implementation {$R *.lfm} { Twm1 } procedure Twm1.MorningRequest(Sender: TObject; ARequest: TRequest;   AResponse: TResponse; var Handled: Boolean);begin   AResponse.Content:= 'Good Morning';   Handled:= true;end; initialization    RegisterHTTPModule('wm', Twm1);end. 
By pressing F9, this is running listening to port 2015.

So, I defined in the nginx.conf file as follows.


--- Code: Text  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---        location /aqrun/  {            fastcgi_pass   127.0.0.1:2015;        #    fastcgi_index  index.php;        #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;            include        fastcgi_params;        }
And... http://localhost/aqrun  displays "Hello World", but I cannot run localhost/aqrun/morning.  This displays "Hello, World" as well. How can I define nginx to process pathinfo?

Navigation

[0] Message Index

[#] Next page

Go to full version