apache httpd extension help

試著忘記壹切 提交于 2019-12-13 05:09:01

问题


I want to create a apache extension for my special protocol wich listens on the same port as apache but on a specific directory or file like php. I need this to power my game with a custom server but not with php. I cant listen on a different port or different server.

I dont want to create a php file or something similar. i need a complete executable program where i can dynamically allocate memory etc. the program is completly outside of the apache server, but the apache 'passes-through' special requests to this program (for example the .foo files or the /foo/ directory.

I need a tutorial or a help to create a custom extension for apache.

UPDATE:

i want to create a daemon running in the background of my server, and then when apache sends a request, it forwarded this to my daemon, and then the daemon generates the request, and then send an answer. this is important that is not like a php script file or a perl because this is not executed once, the program is running all time, and waiting for the apache to send something. i dont know how to communicate with apache. But i think this is not a CGI, because if i read well, the CGI running is like: apache gets the reuest, and then START a new process for my php or perl file, sends the datas through arguments and stdIN, and then when the process ends, reads the answer form the stdOut and send it back, the process then finished.

But my prgram still running. I need to run my program in the background all time because i need to store data in the memory which is loaded at startup.

like this.: http://i53.tinypic.com/v45jzo.jpg


回答1:


You don't need a special extension, just register a CGI handler that calls your processing code.

Edit You can setup apache to proxy requests to your daemon.

You will need to return a properly formatted HTTP response or it wont work. You should read up on Apache and web based communications in general to get a better idea what is needed in your daemon.

ProxyRequests Off

<Proxy *>
Order deny,allow
Allow from all
</Proxy>

ProxyPass /foo http://foo.example.com/bar
ProxyPassReverse /foo http://foo.example.com/bar 

P.S. Writing an Apache extension is much more difficult an not portable.




回答2:


To answer your second question about what CGI is

CGI stands for common gateway interface.

when you register a handler as Byron pointed out you tell apache to give the 'request' to your application. apache listens to the output stdout of your application and returns the result to the user.

The parameters for the application are all supplied via the environment which you can access from your application.

But if you don't understand this stuff you are going to run into problems. such as you must set certain headers.

DC



来源:https://stackoverflow.com/questions/4893108/apache-httpd-extension-help

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!