2

Have server with installed nginx and php-fpm. Some sctript need access to part of site via curl. But it fails. I tried to run curl on server :

curl -v -i alexcoder.info
* About to connect() to alexcoder.info port 80 (#0)
*   Trying 88.198.156.238...
* Connection refused
* couldn't connect to host
* Closing connection #0
curl: (7) couldn't connect to host

But from network sites available :

curl -v -i alexcoder.info
* Rebuilt URL to: alexcoder.info/
* Adding handle: conn: 0x702b10
* Adding handle: send: 0
* Adding handle: recv: 0
* Curl_addHandleToPipeline: length: 1
* - Conn 0 (0x702b10) send_pipe: 1, recv_pipe: 0
* About to connect() to alexcoder.info port 80 (#0)
*   Trying 88.198.156.238...
* Connected to alexcoder.info (88.198.156.238) port 80 (#0)
> GET / HTTP/1.1
> User-Agent: curl/7.32.0
> Host: alexcoder.info
> Accept: */*
> 
< HTTP/1.1 200 OK

HTTP/1.1 200 OK

nginx logs does not contain any errors aboout this. I tried to flush iptables rules but it take no effect.

What it may be?

2

Multiple servers

You need to setup a listener for each network interface you want Nginx to respond to:

server {
    listen       80;
    server_name  localhost;

    #charset koi8-r;

    #access_log  logs/host.access.log  main;

    location / {
        root   html;
        index  index.html index.htm;
    }

You likely already have a server {..} section that's listening on the actual interface that your system binds to when it gets an IP address.

Multiple listeners

You can also add multiple Listen lines to a server {..} section like so:

Examples

listen     *:80;

or

listen localhost:80; listen 127.0.0.1:80; listen 12.34.56.78:80;

I would likely do it using this second method! See this article for more examples, titled: - Basic Nginx Configuration.

References

  • @alexgauss1994 - yup, thanks for the Q! – slm Feb 26 '14 at 22:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.