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 using Nginx as my webserver for the first time. I didn't have any trouble to set it up and everything works great. The problem came when the designer asked me if he could send me "the icon in the title bar" to "put it up there".

# /opt/nginx/conf/nginx.conf
...
server {
    listen 80 ;
    server_name *.website.com website.com;
    root /home/webuser/sites/website;
}

My directory:

/home/webuser/sites/website/
|_ index.html
|_ main.css
|_ favicon.ico

Is it possible to put a specific favicon.ico to each Virtual Host? Where should you put that file and how can you configure it?

EDIT:

I just realized that it was a completely different problem. Both answers were right but my problem was the permission. I don't know why the file favicon.ico ended up having permissions 600 and of course the moment I did:

chmod +r favicon.ico

Worked like a charm. I will leave this here if it happens to someone else.

share|improve this question
    
The 600 permission might relate to the umask (umask for that user is set to 077 for example). –  jcisio Sep 5 '11 at 15:06
    
The permissions issue fixed it for me as well! –  Kzqai Oct 16 at 16:15

3 Answers 3

up vote 6 down vote accepted

favicon.ico file should be placed in website root directory which is defined by nginx root directive. Or you could pass URL to favicon by using following code in HTML:

<link rel="shortcut icon" href="http://example.com/myicon.ico" />

share|improve this answer
    
I have my favicon.ico file in there... still not working –  ersamy Sep 5 '11 at 14:04
1  
Check grep favicon.ico nginx-{access,error}.log and check output from file favicon.ico - IE doesn't understand anything other than ICO format. Also, you config shows only one VirtualHost. –  AlexD Sep 5 '11 at 14:15
    
good with php crap, not good with static files setup –  holms Sep 16 '13 at 17:27

This is how we do it in our specific vhost config (sites-available/[vhostconfigfile] under the server directive:

location = /favicon.ico { alias /var/www/media/images/favicon.X.ico; }

That way you can put it anywhere you want with no html whatsoever...

share|improve this answer
    
This is perfect for my situation. I have a simple index.htm with links to Webmin and phpVirtualBox for my server and I wanted all 3 to have the same custom favicon. –  RyanScottLewis May 17 '12 at 0:03
    
why you need = in there? –  holms Sep 16 '13 at 17:28
    
The = may not be required, but it may be a modest speedup and is correct. See the docs: nginx.org/en/docs/http/ngx_http_core_module.html#location –  Scott Stafford Oct 15 at 13:53

This means, wherever the virtual host's files are taken from (root directory) you should put that specific favicon.ico file.

share|improve this answer

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.