> ## Content Index
> Fetch the complete content index at: https://discoverghost.com/blog/llms.txt
> Use this file to discover other available public pages before exploring further.

# Domain forwarding with Nginx
- URL: https://discoverghost.com/blog/domain-forwarding-with-nginx/
- Published: 2013-11-03T14:25:23.000Z
- Updated: 2013-11-03T16:27:48.000Z
- Author: Harish Chouhan
- Tags: Tips, Nginx, Setup, #Import 2026-07-20 02:58, #Import 2026-10-22 16:21

Most web designers I know who use WordPress are aware of .htaccess file which can be used to forward domains with www in front to non www domain. Google Webmaster tools offers a way to set a preferred domain but now for all Ghost users who are installing and doing the setup themselves, how do we set a forwarding system to either forward www.yourdomain.com to yourdomain.com or the reverse of it?

To do this, you would have to edit your Nginx configuration file. If you have followed the instructions on [https://www.digitalocean.com/community/articles/how-to-use-the-digitalocean-ghost-application](https://www.digitalocean.com/community/articles/how-to-use-the-digitalocean-ghost-application?ref=discoverghost.com) to setup Ghost, then the steps to set the forwarder would be:

SSH into your server and then type `nano /etc/nginx/conf.d/default.conf`. The contents of this file would be similar to below example:

server {
    listen 80;
    server_name  my-ghost-blog.com;
    location / {                               
            proxy_pass http://localhost:2368/;
            proxy_set_header Host $host;
            proxy_buffering off;
    }
}

Now to forward www.my-ghost-blog.com to just my-ghost-blog, you need to add below code on top of the existing code.

server {
    listen 80;
    server_name www.my-ghost-blog.com;
    return 301 $scheme://my-ghost-blog.com$request_uri;
}

To save first exist nano by pressing `Ctrl + X` and then type `Y` and press enter.

Once done, simply restart Nginx by typing `service nginx restart` and if things work, your www domain would point to the one without www.