fcl-web : Request IP lazarus / 38-Networking and Web Programming ---------------------------------------------------------------------- Mukatai · 2013-11-07 16:21 Hello, I create an application based on simplehttpserver exemple of fcl-web. (lazarus\fpc\2.6.2\source\packages\fcl-web\examples\httpserver) In TTestHTTPServer.HandleRequest procedure, I am trying to get the ip address of request. I can get the useragent & cookies but i can't get the ip. How can I get the IP of the request ? Another query on this exemple, on linux (with a raspberry) when i compil & execut the code i have this error : Binding of socket failed: 80 To not get this error I have to start the application with sudo. How can I do to not have this problem ? (For debugging) Thanks, Bye. ---------------------------------------------------------------------- Leledumbo · 2013-11-07 16:45 QuoteHow can I get the IP of the request ?Check request headers, it should be one of them. QuoteTo not get this error I have to start the application with sudo. How can I do to not have this problem ? (For debugging)Try another port, it might be used already. Anyway, Linux tend to release used port a little later after it's closed. In my desktop, I usually need to wait about 10 seconds before trying to bind the same port. ---------------------------------------------------------------------- Mukatai · 2013-11-08 09:15 Hello, Thanks for your reply. Quote from: Leledumbo on November 07, 2013, 05:45:31 pmQuoteHow can I get the IP of the request ?Check request headers, it should be one of them.X-Forwarded-For could be correspond but it's not avialable in fcl-web component. And it's not really what I want. I think it is in ARequest.Connection.Socket but i don't find  Quote from: Leledumbo on November 07, 2013, 05:45:31 pmQuoteTo not get this error I have to start the application with sudo. How can I do to not have this problem ? (For debugging)Try another port, it might be used already. Anyway, Linux tend to release used port a little later after it's closed. In my desktop, I usually need to wait about 10 seconds before trying to bind the same port. I can try all port it will not work. The only solution is launch application with sudo right and i want lazarus launch my application with sudo rights. It's possible ? Bye. ---------------------------------------------------------------------- Leledumbo · 2013-11-08 17:06 QuoteX-Forwarded-For could be correspond but it's not avialable in fcl-web componentTry ARequest.RemoteAddr. Quotei want lazarus launch my application with sudo rights. It's possible ?Run->Run Parameters->Use Launching Application, use $(TargetCmdLine) IDE macro to point to your executable. ---------------------------------------------------------------------- Mukatai · 2013-11-13 15:35 Hello, Quote from: Leledumbo on November 08, 2013, 06:06:33 pmRun->Run Parameters->Use Launching Application, use $(TargetCmdLine) IDE macro to point to your executable. Don't work for me. But the simplehttpserver exemple of fcl-web work perfect and my console application have the error message (Binding of socket failed). So I need to find the difference ... Quote from: Leledumbo on November 08, 2013, 06:06:33 pmTry ARequest.RemoteAddr The result is still empty (test in local and remote, on more browser). I tried also: - ARequest.RemoteAddresse - ARequest.RemoteHost - ARequest.Host - ARequest.From - ARequest.Location and other but the result is the same : empty  Another idea? Thanks, Bye. ---------------------------------------------------------------------- rasberryrabbit · 2013-11-14 04:55 how about "ARequest.Connection.Socket.RemoteAddress"? My failed project src may help ---------------------------------------------------------------------- Leledumbo · 2013-11-14 08:53 QuoteThe result is still empty (test in local and remote, on more browser). I tried also: - ARequest.RemoteAddresse - ARequest.RemoteHost - ARequest.Host - ARequest.From - ARequest.Location and other but the result is the same : empty  Another idea?Probably a 2.6.2 bug, I used 2.7.1 and it works here. ---------------------------------------------------------------------- Mukatai · 2013-11-14 11:02 Hi, Ok I'll test on FPC 2.7.1 and it's RemoteAddr where you see the ip request ? Thanks for your help Leledumbo. @+ ---------------------------------------------------------------------- Leledumbo · 2013-11-14 13:37 QuoteOk I'll test on FPC 2.7.1 and it's RemoteAddr where you see the ip request ?Try the attached project. ---------------------------------------------------------------------- Mukatai · 2013-11-14 14:03 After test with FPC 2.7.1 RemoteAddr & RemoteAddress return IP of request. I tested your project and all property are empty except RemoteAddr (With FPC 2.7.1 but all are empty with FPC 2.6.2). Now I must find a way to update my rapsberry with FPC 2.7.1... @+ ---------------------------------------------------------------------- Mukatai · 2013-11-14 14:16 Quote from: parcel on November 14, 2013, 05:55:37 amhow about "ARequest.Connection.Socket.RemoteAddress"? My failed project src may help  ARequest.Connection.Socket.RemoteAddress need convert a sockaddr to string. But i think ARequest.Connection.Socket.RemoteAddress = ARequest.RemoteAddress with convert... @+ ---------------------------------------------------------------------- almp1 · 2016-12-21 13:53 If you use load balance try again for apache2+centos6 yum -y install httpd-devel mkdir /usr/local/src/mod_remoteip cd /usr/local/src/mod_remoteip/ wget https://raw.githubusercontent.com/ttkzw/mod_remoteip- httpd22/master/mod_remoteip.c wget https://raw.githubusercontent.com/ttkzw/mod_remoteip- httpd22/master/mod_remoteip.conf wget https://raw.githubusercontent.com/ttkzw/mod_remoteip- httpd22/master/Makefile yum -y install gcc apxs -i -c -n mod_remoteip.so mod_remoteip.c crete file in /etc/httpd/conf.d/mod_remoteip.conf LoadModule remoteip_module modules/mod_remoteip.so RemoteIPHeader X-Forwarded-For RemoteIPProxiesHeader X-Forwarded-By service httpd restart ---------------------------------------------------------------------- Mukatai · 2017-01-18 22:10 Hi, Finally i created my own http server based on socket with synapse. (3 years ago) And fcl-web don't use httpd. (to my knowledge) @+ ---------------------------------------------------------------------- Thaddy · 2017-01-30 11:48 Quote from: Mukatai on January 18, 2017, 11:10:28 pmAnd fcl-web don't use httpd. (to my knowledge) Of course it does... There are also the native httpdxx packages, btw. ---------------------------------------------------------------------- Leledumbo · 2017-01-31 07:53 Quote from: Thaddy on January 30, 2017, 12:48:12 pmQuote from: Mukatai on January 18, 2017, 11:10:28 pmAnd fcl-web don't use httpd. (to my knowledge) Of course it does... There are also the native httpdxx packages, btw. No, it doesn't (for serving). httpdXY packages are provided to create apache modules, which is only one out of several ways to create a web application. The embedded HTTP server and F(CGI) doesn't use them at all. ---------------------------------------------------------------------- Thaddy · 2017-01-31 08:26 What?! httpd is nothing more than a webserver daemon and fcl-web can be used to write a webserver last time I used it... https://en.wikipedia.org/wiki/Httpd /fpctrunk/packages/fcl-web/examples/httpserver That's either sick or ignorant ---------------------------------------------------------------------- Leledumbo · 2017-01-31 10:35 Quote from: Thaddy on January 31, 2017, 09:26:26 amWhat?! httpd is nothing more than a webserver daemon and fcl-web can be used to write a webserver last time I used it... https://en.wikipedia.org/wiki/Httpd /fpctrunk/packages/fcl-web/examples/httpserver That's either sick or ignorant Watch your words again: Quote"And fcl-web don't use httpd. (to my knowledge)" "Of course it Quotedoes..."So you stated that fcl-web uses httpd to provide its functionality, which is incorrect. ---------------------------------------------------------------------- Thaddy · 2017-01-31 11:05 Quote from: Leledumbo on January 31, 2017, 11:35:45 amSo you stated that fcl-web uses httpd to provide its functionality, which is incorrect. No, I stated that httpd MEANS webserver.... And you can write a webserver, daemon or not, with fcl-web. httpd is not defined as a protocol. It simply means a webserver implemented as a daemon. Nothing more, nothing less. You are studying informatics. Don't look stupid. I do not have to watch my words, I tell it like it is. Harsh. and hard if I need to. Reflect on this. Apologies accepted. ---------------------------------------------------------------------- rvk · 2017-01-31 11:23 So fcl-web doesn't USE httpd. It IMPLEMENTS it. If you say it USES httpd it means it uses (an external) httpd. If you see httpd as protocol.... fcl-web does use the "http protocol". But httpd isn't a protocol. It's a deamon. It just interpretation of the words here. You can read it either way but I think "implements" would be better suited here over "uses". ---------------------------------------------------------------------- Thaddy · 2017-01-31 12:19 No. It is a matter of fact.