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.
This is how we do it in our specific vhost config (
sites-available/[vhostconfigfile]
) under the server directive:That way you can put it anywhere you want with no html whatsoever.
The ".X." is not required at all, and only denotes that you can change this filename to anything you like. I simply use the ".X." as a placeholder to identify the specific sub domain that I am referencing. Its purely for organization.
favicon.ico
file should be placed in website root directory which is defined by nginxroot
directive. Or you could pass URL to favicon by using following code in HTML:<link rel="shortcut icon" href="http://example.com/myicon.ico" />
This means, wherever the virtual host's files are taken from (root directory) you should put that specific favicon.ico file.