Tell me more ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Is it possible to use nginx as ordinal http/https proxy? (not reverse http proxy)

UPDATE: Yes, i know about squid/oops/tinyproxy/etc. Please do not answer if you dont know answer to question (or just for rating score).

share|improve this question

3 Answers

After some expiriments, i've found working for me configuration.

server {

  server_name ~^(www\.)?(?<domain>.+)$;
  access_log /var/log/nginx/proxy.access.log main;
  error_log /var/log/nginx/proxy.error.log crit;
  listen 10.255.1.13:8080;
  resolver 8.8.8.8;
  location / {
    proxy_pass http://$domain;
    proxy_redirect off;
    proxy_set_header Host $host;
    # Optional headers 
    # proxy_set_header X-Real-IP $remote_addr;
    # proxy_set_header X-Forwarded-For
    # $proxy_add_x_forwarded_for;
  }
}

This configuration works only for HTTP, not for HTTPS

share|improve this answer
1  
Good job! Few hints. 1: listen ... default_server. 2: server_name "" or server_name _. 2: proxy_pass $scheme://$http_host. The limitations: poxying to upstreams with port 80 only; does not process redirects itself. – Alexander Azarov Aug 8 '11 at 14:00

i think the short answer is no, it was not written for forward proxying

share|improve this answer

If you want to use an HTTP/HTTPS proxy, you should use Squid. It was written to do exactly that. Nginx was written to act as a reverse proxy and load balancer, but not a forward proxy.

share|improve this answer
I know about squid/oops/tinyproxy/etc. I just ask this question for the sake of academic interest – vlad Aug 8 '11 at 11:33

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.