# Nginx tips for localhost development

**URL:** <https://www.ruby-forum.com/t/nginx-tips-for-localhost-development/228236>\
**Category:** NGINX\
**Created:** [April 15, 2013, 4:51am UTC](https://www.ruby-forum.com/t/nginx-tips-for-localhost-development/228236 "2013-04-15T04:51:06Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ian\_MSEvans](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/7bcc69/32.png) [@Ian\_MSEvans](https://www.ruby-forum.com/u/Ian_MSEvans)\
**Post date:** [April 15, 2013, 4:51am UTC](https://www.ruby-forum.com/t/nginx-tips-for-localhost-development/228236/1 "2013-04-15T04:51:06Z")

</div>

As I’m about to launch some major additions to my site (and launch  
another  
site) I’ve been starting to get my act together in regards to  
development,  
e.g. finally starting to use git, getting ready for a responsive  
redesign,  
etc.

I’ve realized that it would probably be wise to develop locally by  
running  
a localhost server in a linux VM on my laptop and desktop.

Can anyone give me any tips (or point me to a tutorial/article) that  
would  
show me how to set up nginx for localhost testing? Is it possible for me  
to create a setup in nginx so both [www.example.com](http://www.example.com) and  
[www.mynewsiteexample.com](http://www.mynewsiteexample.com) would be served by the localhost nginx?

Thanks for any advice!

---

<div class="post-metadata">

**Author:** ![Ian\_MSEvans](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/7bcc69/32.png) [@Ian\_MSEvans](https://www.ruby-forum.com/u/Ian_MSEvans)\
**Post date:** [April 15, 2013, 3:17pm UTC](https://www.ruby-forum.com/t/nginx-tips-for-localhost-development/228236/2 "2013-04-15T15:17:25Z")

</div>

you might want to play with your /etc/hosts.

Posted at Nginx Forum:

> **[Re: nginx tips for localhost development](https://forum.nginx.org/read.php?2,238368,238372#msg-238372)**
>
> As I'm about to launch some major additions to my site (and launch another site) I've been starting to get my act together in regards to development, e.g. finally starting to use git, getting ready for a responsive redesign, etc. I've realized that...

---

<div class="post-metadata">

**Author:** ![Ian\_MSEvans](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/7bcc69/32.png) [@Ian\_MSEvans](https://www.ruby-forum.com/u/Ian_MSEvans)\
**Post date:** [April 15, 2013, 7:49pm UTC](https://www.ruby-forum.com/t/nginx-tips-for-localhost-development/228236/3 "2013-04-15T19:49:42Z")

</div>

On Sun, Apr 14, 2013 at 10:50:15PM -0400, Ian M. Evans wrote:

Hi there,

> I’ve realized that it would probably be wise to develop locally by running  
> a localhost server in a linux VM on my laptop and desktop.
> 
> Can anyone give me any tips (or point me to a tutorial/article) that would  
> show me how to set up nginx for localhost testing? Is it possible for me  
> to create a setup in nginx so both [www.example.com](http://www.example.com) and  
> [www.mynewsiteexample.com](http://www.mynewsiteexample.com) would be served by the localhost nginx?

On the nginx side, there should be approximately nothing special to do.

The nginx.conf that works on your production server can be put onto your  
development server; “listen” directives which specify ip addresses may  
need to be changed, and file names may need to be changed if you have  
a different layout.

But other than that, not much about nginx cares.

The main thing you will need, if you use multiple server{} blocks with  
different server\_name directives, is to make sure that whatever client  
you are testing with (== web browser) resolves the names that you use  
to be an address that your test nginx listens on. /etc/hosts is probably  
the simplest way to arrange that.

If you’re comfortable testing using “curl”, you don’t even need that –  
just add a suitable “-H Host:” argument to each command.

## f

Francis D. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![Ian\_MSEvans](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/7bcc69/32.png) [@Ian\_MSEvans](https://www.ruby-forum.com/u/Ian_MSEvans)\
**Post date:** [April 23, 2013, 8:12am UTC](https://www.ruby-forum.com/t/nginx-tips-for-localhost-development/228236/4 "2013-04-23T08:12:18Z")

</div>

On Mon, April 15, 2013 1:49 pm, Francis D. wrote:

> On the nginx side, there should be approximately nothing special to do.
> 
> The nginx.conf that works on your production server can be put onto your  
> development server; “listen” directives which specify ip addresses may  
> need to be changed, and file names may need to be changed if you have  
> a different layout.  
> [snip]

Thanks for the advice.
