Forward proxy frontend using OpenResty

408 views
Skip to first unread message

Anton

unread,
Jul 8, 2014, 4:39:08 AM7/8/14
to openre...@googlegroups.com
Hello everybody,

I need to setup a frontend server in front of usual forward proxy (like
squid).

I tried to use Nginx for that purpose, but it can't handle such
requests, because in this case Host header is not present and hostname
is part of URL. Eg nginx expects:
GET /
Host: google.com
but browser sends:
GET http://google.com/

Is it possible to modify this Nginx behavoiur using OpenResty?

It would be great if nginx just proxy such requests without modification
of URL part.

Thank you,
Anton Habin.



Peter Booth

unread,
Jul 8, 2014, 7:51:56 AM7/8/14
to openre...@googlegroups.com

Anton,

My nginx servers are configured to add a host header if one is missing. 

This example is for a site that uses Apache, but has an nginx caching proxy in f
ront of the pool of apache servers ...

  # Common proxy settings
    proxy_set_header  X-Real-IP  $remote_addr;
    proxy_set_header  X-Forwarded-For $proxy_add_x_forwarded_for;

   # Return these headers back from the Apache server to the client
    proxy_pass_header Set-Cookie;
    proxy_pass_header Content-Type;
    proxy_pass_header Content-Disposition;
    proxy_pass_header Content-Length;
    proxy_http_version 1.1;
    proxy_set_header Connection "";
    proxy_redirect off;
    proxy_read_timeout 300;

    server {
        listen 80 default deferred;

        root /home/docroot/prod;
        proxy_set_header Connection "";

        # If the host header isn't set, we set it explicitly to www.mydomain.com
        set $the_host_header $host;
        set_if_empty $the_host_header 'www.mydomain.com';
        proxy_set_header Host $the_host_header;
        access_log  /home/nginx/openresty/nginx/logs/access.log  main buffer=32k;


Hope this helps,

Peter



--
You received this message because you are subscribed to the Google Groups "openresty-en" group.
To unsubscribe from this group and stop receiving emails from it, send an email to openresty-en...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages