こんな感じか?

location /rep2 {
proxy_pass http://localhost:40080;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
}