NGINX as a forward proxy

I am currently using "tinyproxy" for some outgoing connections, that positively need to use a proxy. I am also using NGINX as a reverse proxy, mostly as an SSL endpoint and multiplexer, for some incoming connections.

I would like to get rid of "tinyproxy", and have just one running service instead of two.

Officially, NGINX cannot work as a forward proxy, but there exists an out-of-tree extension (ngx_http_proxy_connect_module), that can provide this functionality.

Would it be possible to add this module to OpenWrt? Do you think it could be relatively easy for somebody to build such module themselves?

Thanks!

server {
    listen       8888;

    location / {
        resolver x.x.x.x; # might be needed
        proxy_pass $scheme://$http_host$request_uri;
    }
}

give a try now

1 Like

Thanks... but I also need HTTPS.

You need build custom nginx opkg package with ngx_http_proxy_connect_module.
Build custom package for OpenWRT:
http://dvblog.soabit.com/building-custom-openwrt-packages-an-hopefully-complete-guide/
Build ngx_http_proxy_connect_module for x86:
https://www.alibabacloud.com/blog/how-to-use-nginx-as-an-https-forward-proxy-server_595799

1 Like

Thanks, I will try this!