Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I'm running TileMill, which is listening to port 20008 and 20009, from localhost. I want 20009 to be only accessed through nginx on port 80 (with simple auth). I want 20008 to be accessible "directly" from the outside.

server {
   listen 80;
   server_name localhost;
   location / {
        proxy_set_header Host $http_host;
        proxy_pass http://127.0.0.1:20009;
        auth_basic "Restricted";
        auth_basic_user_file htpasswd;
    }
}
server {
   listen 20008;
   server_name localhost;
   location / {
        proxy_set_header Host $http_host;
        proxy_pass http://127.0.0.1:20008;
    }
}

The obvious problem is that nginx can't listen on port 20008 - it's already being used by TileMill.

Restarting nginx: nginx: [emerg] bind() to 0.0.0.0:20008 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:20008 failed (98: Address already in use)

Is there a way where nginx can listen externally without conflicting with the other service listening internally? (Changing localhost to the server's external IP didn't work.)

share|improve this question

1 Answer 1

up vote 1 down vote accepted

Change your listen statement to include your external IP, eg:

listen 1.2.3.4:20008;

share|improve this answer
    
Perfect, thanks. –  Steve Bennett May 3 '13 at 1:27
    
Yeah, sorry, I misread - deleted my comment now. –  Steve Bennett May 3 '13 at 1:27

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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