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 am trying to port my local environment on a mac to use nginx

from the logs I first got [emerg] 9449#0: bind() to 0.0.0.0:80 failed (13: Permission denied) but running sudo nginx solved this

now if I input the address http://njsphp.dev, it just downloads a file?

in the conf I have set a virtual host and I have put the name in the hosts file

server{
    listen       80;
    listen     njsphp.dev;

    server_name njsphp.dev;
    root /Users/redres/Webdev/nodejsphp;
    index index.phtml index.htm;
         location / {
        }
}

thanks

share|improve this question

1 Answer 1

up vote 1 down vote accepted

Only root is allowed to bind ports <1024. Check that you run nginx as regular user or www-data user or root. Nginx has drop privilages mechanism to do it. You run it as root, nginx binds to 80 then drop privilages to user pointed in configuration.

UPDATE:

Of course giving root/admin privilages is only one method. You can use selinux or CAP_NET_ADMIN linux capability to give access only to binding port below 1024 and nothing else.

share|improve this answer
    
thanks, I figured that one out –  Richard Sep 29 '13 at 12:40
    
@spinus, could you explain this in more detail please? I don't quite understand and could use this solution. Thank you :) –  Andy Jones Oct 19 '13 at 4:24
    
@AndyJones there is nothing to explain. Only privileges (root/administrator or application with privileges to do that) can use ports below 1024. So you have to use ports above 1024 or grant privileges to application. –  spinus Oct 21 '13 at 19:35
    
Keep in mind that neither SELinux nor Linux capabilities are available on this user's Mac. –  Michael Hampton Jul 5 at 15:22

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.