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 have a small web server that serves requests on port 5010 rather than 80.

I would like to use nginx as a front end proxy to receive requests on port 80 and then let those requests be handle by port 5010.

I have installed nginx successfully and it runs smoothly on Ubuntu Karmic.

But, my attempts to reconfigure the default nginx.conf have not been successful.

I tried including in the server directive the listen argument for port 5010.

I have also tried proxy_pass directive.

Any suggestions on changes that need to be made or directives that need to be set in order to just have port forwarding.

share|improve this question

2 Answers 2

up vote 3 down vote accepted

I'm assuming that nginx is not the server listening on port 5010 as well as 80, correct? Something else is listening on 5010 and you wish to have nginx proxy to that server?

If that's the case, here's a nice sample config I've used in the past with success:

server {
        listen       80;
        server_name  <YOUR_HOSTNAME>;
        location / {
            proxy_pass         http://127.0.0.1:5010/;
            proxy_redirect     off;

            proxy_set_header   Host             $host;
            proxy_set_header   X-Real-IP        $remote_addr;
            proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;

            client_max_body_size       10m;
            client_body_buffer_size    128k;

            proxy_connect_timeout      90;
            proxy_send_timeout         90;
            proxy_read_timeout         90;

            proxy_buffer_size          4k;
            proxy_buffers              4 32k;
            proxy_busy_buffers_size    64k;
            proxy_temp_file_write_size 64k;
        }
}

I believe that should accomplish what you're seeking. Good luck!

share|improve this answer
    
Thanks this was just what I was looking for... –  Ted Karmel Aug 18 '10 at 13:00

Pretty minimalist -- I've left the proxy settings as default, though you may want to look in to it to adjust to your needs.

# NGINX configuration

# System configuration ##################
worker_processes  3;
events {
    worker_connections  1024;
}
user nobody;

# Web configuration #####################
http {
    server {
        listen 80 default;
        location / {
            proxy_set_header   X-Real-IP        $remote_addr;
            proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;
            proxy_set_header   Host             $host;

            proxy_pass http://127.0.0.1:5010/;

        }
    }
}
share|improve this answer
    
Tyler - your minimal solution is good. That's what I wanted. Would give you points if I could but still new on serverfault –  Ted Karmel Aug 18 '10 at 13:01

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.