Closed o1da closed 8 years ago
I have just realized that I wanted to use it as forward proxy and example speaks about reverse proxy, so the solution would be Squid configured like the reverse proxy - URL for the endpoint configured there and LUA connected to Squid. Am I correct or completely wrong? :)
The best way to handle external connections is to create an nginx upstream (local reverse proxy) and then use ngx.location.capture to do requests to this local endpoint
in nginx.conf
location ~* /interneturl/(.*)$ {
proxy_pass http://www.someinternetsite.com/$1$is_args$args;
proxy_redirect off;
proxy_http_version 1.1;
proxy_set_header Connection "";
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
then in lua script: local resp = ngx.location.capture("/interneturl/content/" .. param, { method = ngx.HTTP_GET })
etc...
only time I would use lua resty http is when you need to dynamically set target domain / IP
so you dont need squid, just use nginx for reverse proxy, this way all is non-blocking
Thank you :)
How to configure a connection to e.g. Squid proxy which runs on localhost? I need to send requests to an endpoint on the internet through this proxy. In the proxy example, it seems that
httpc:connect(HOST, PORT)
is for endpoint configuration. So how should I tell LUA to use the proxy on the specific port on the localhost? Is it possible?