# NGINX as a forward proxy

**URL:** <https://forum.openwrt.org/t/nginx-as-a-forward-proxy/119958>\
**Category:** For Developers\
**Created:** [February 11, 2022, 10:32am UTC](https://forum.openwrt.org/t/nginx-as-a-forward-proxy/119958 "2022-02-11T10:32:06Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![eduperez](https://forum.openwrt.org/user_avatar/forum.openwrt.org/eduperez/32/2066_2.png) [@eduperez](https://forum.openwrt.org/u/eduperez)\
**Post date:** [February 11, 2022, 10:32am UTC](https://forum.openwrt.org/t/nginx-as-a-forward-proxy/119958/1 "2022-02-11T10:32:06Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![grrr2](https://forum.openwrt.org/user_avatar/forum.openwrt.org/grrr2/32/50931_2.png) [@grrr2](https://forum.openwrt.org/u/grrr2)\
**Post date:** [February 11, 2022, 10:43am UTC](https://forum.openwrt.org/t/nginx-as-a-forward-proxy/119958/2 "2022-02-11T10:43:46Z")

</div>

```
server {
    listen 8888;

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

```

give a try now

---

<div class="post-metadata">

**Author:** ![eduperez](https://forum.openwrt.org/user_avatar/forum.openwrt.org/eduperez/32/2066_2.png) [@eduperez](https://forum.openwrt.org/u/eduperez)\
**Post date:** [February 11, 2022, 12:56pm UTC](https://forum.openwrt.org/t/nginx-as-a-forward-proxy/119958/3 "2022-02-11T12:56:38Z")

</div>

Thanks... but I also need HTTPS.

---

<div class="post-metadata">

**Author:** ![polonez](https://forum.openwrt.org/letter_avatar/polonez/32/5_5575768a8748004e209b776fc1b2916d.png) [@polonez](https://forum.openwrt.org/u/polonez)\
**Post date:** [March 9, 2022, 10:25am UTC](https://forum.openwrt.org/t/nginx-as-a-forward-proxy/119958/4 "2022-03-09T10:25:18Z")

</div>

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/](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](https://www.alibabacloud.com/blog/how-to-use-nginx-as-an-https-forward-proxy-server_595799)

---

<div class="post-metadata">

**Author:** ![eduperez](https://forum.openwrt.org/user_avatar/forum.openwrt.org/eduperez/32/2066_2.png) [@eduperez](https://forum.openwrt.org/u/eduperez)\
**Post date:** [March 9, 2022, 1:31pm UTC](https://forum.openwrt.org/t/nginx-as-a-forward-proxy/119958/5 "2022-03-09T13:31:14Z")

</div>

Thanks, I will try this!
