# Is this the best way to use nginx as a reverse proxy?



## tingo (Mar 1, 2012)

For a specific use, I needed a reverse web proxy (see this thread if you want to know the gory details) on my firewall. The use case is simple: the web proxy should forward all http requests to an internal web server.
Since www/nginx has very few dependencies, I decided to use that (I'm much more familiar with apache, but since it is a much more "heavy" port I didn't want to install it on my firewall).
After installing nginx, I changed the (default)  /usr/local/etc/nginx/nginx.conf by changing the "server" clause within the "http" clause like this:

```
server {
        listen       80 default;
        server_name  localhost;

        location / {
                proxy_pass http://internal-web-server/;
                proxy_set_header X-Real-IP  $remote_addr;
                proxy_set_header Host $host;
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        }
```
It appears to work: I can now access my internal web sites, and everything works as expected.
One question: is this the best / most optimal way to do it?


----------

