Monday 15 February 2010

node.js - nodejs configuration httpd.conf -


I am used to insert configuration items in apache and httpd.conf

Where are the types? The configuration is to go into a node environment, for example, I want to make sure that only GET, POST and PUT are accepted and the head and trace are not accepted.

"text">

node.js system only Technically, you can reapply the Apache HTTP server in node. Js, duplicate its behavior and its structure structure. but do you?

I believe that you node. Using JS module See Document: There is no way to read the configuration from a file. The program has been created using the server http.createServer . You provide callback that listens to requests This callback provides a http.IncomingMessage parameter (the first parameter) that you need.

Here's an example:

  // Load Modules var http = Required ('http'); // HTTP server var server = http.createServer (function (request, response) {// "request request" request an object request console.log ('request!') To know everything about; // method ( 'GET', 'POST', 'PUT, etc.): Console.log (' http method: '+ request.method); // url: console.log (' http url: '+ request.url); / / Header: console.log ('follow HTTP header:'); console.log (request.headers); // client address: console.log ('client address:' + request.socket.address (). Address);} ); Listen on / port 8000 servers. List 7 (8000);   

If you really want a configuration file, you have to make it yourself myself. I suggest creating a JSON configuration file because it directly JSON.parse () . Then use only your configuration object program to achieve what you want.

No comments:

Post a Comment