hell0w0rd
Продвинутый новичок
У меня он не работает никак. Попробовал по всякому, вот как сделал на vps (вдруг osx глючит).
Что я делаю не так?
PHP:
// /home/nkt/test.js
var http = require('http');
http.createServer(function (req, res) {
res.setHeader('X-Accel-Redirect', '/test.js');
res.end();
}).listen(3333);
PHP:
// nginx
server {
listen localhost:4000;
server_name localhost;
root /home/nkt;
location / {
internal;
proxy_pass http://127.0.0.1:3333;
}
}
Код:
$ node test.js &
[1] 1912
$ curl -v http://localhost:3333/
* Hostname was NOT found in DNS cache
* Trying ::1...
* connect to ::1 port 3333 failed: Connection refused
* Trying 127.0.0.1...
* Connected to localhost (127.0.0.1) port 3333 (#0)
> GET / HTTP/1.1
> User-Agent: curl/7.35.0
> Host: localhost:3333
> Accept: */*
>
< HTTP/1.1 200 OK
< X-Accel-Redirect: /test.js
< Date: Mon, 09 Mar 2015 19:13:48 GMT
< Connection: keep-alive
< Transfer-Encoding: chunked
<
* Connection #0 to host localhost left intact
$ curl -v http://localhost:4000/
* Hostname was NOT found in DNS cache
* Trying ::1...
* connect to ::1 port 4000 failed: Connection refused
* Trying 127.0.0.1...
* Connected to localhost (127.0.0.1) port 4000 (#0)
> GET / HTTP/1.1
> User-Agent: curl/7.35.0
> Host: localhost:4000
> Accept: */*
>
< HTTP/1.1 404 Not Found
* Server nginx is not blacklisted
< Server: nginx
< Date: Mon, 09 Mar 2015 19:13:58 GMT
< Content-Type: text/html
< Content-Length: 162
< Connection: keep-alive
<
<html>
<head><title>404 Not Found</title></head>
<body bgcolor="white">
<center><h1>404 Not Found</h1></center>
<hr><center>nginx</center>
</body>
</html>
* Connection #0 to host localhost left intact