# Nextjs app, should I use nginx in front of it

**URL:** <https://community.fly.io/t/nextjs-app-should-i-use-nginx-in-front-of-it/22084>\
**Category:** JavaScript\
**Tags:** nodejs\
**Created:** [October 1, 2024, 5:21pm UTC](https://community.fly.io/t/nextjs-app-should-i-use-nginx-in-front-of-it/22084 "2024-10-01T17:21:22Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Bonadio](https://sea1.discourse-cdn.com/fly1/user_avatar/community.fly.io/bonadio/32/43194_2.png) [@Bonadio](https://community.fly.io/u/Bonadio)\
**Post date:** [October 1, 2024, 5:21pm UTC](https://community.fly.io/t/nextjs-app-should-i-use-nginx-in-front-of-it/22084/1 "2024-10-01T17:21:22Z")

</div>

Hi, when I run a Node.js app on AWS EC2, I usually run it behind an Nginx reverse proxy to avoid exposing Node.js directly to the internet.

Should I do the same here?

I understand that every [Fly.io](http://Fly.io) machine runs behind a proxy (Fly proxy). Is this enough to provide the same level of security that Nginx offers?

Thanks

---

<div class="post-metadata">

**Author:** ![khuezy](https://avatars.discourse-cdn.com/v4/letter/k/4da419/32.png) [@khuezy](https://community.fly.io/u/khuezy)\
**Post date:** [October 1, 2024, 5:27pm UTC](https://community.fly.io/t/nextjs-app-should-i-use-nginx-in-front-of-it/22084/2 "2024-10-01T17:27:11Z")

</div>

Fly proxy has nothing to do with making your app private. To do so, you can release the public ips. You can proxy all your private apps under a single nginx server and add some basic auth or whitelist ips there.

---

<div class="post-metadata">

**Author:** ![Bonadio](https://sea1.discourse-cdn.com/fly1/user_avatar/community.fly.io/bonadio/32/43194_2.png) [@Bonadio](https://community.fly.io/u/Bonadio)\
**Post date:** [October 1, 2024, 5:59pm UTC](https://community.fly.io/t/nextjs-app-should-i-use-nginx-in-front-of-it/22084/3 "2024-10-01T17:59:14Z")

</div>

The app is public, I want to know what is the best practice to expose a Nextjs app in [fly.io](http://fly.io).  
I would rather not use nginx if I don’t need to.

---

<div class="post-metadata">

**Author:** ![khuezy](https://avatars.discourse-cdn.com/v4/letter/k/4da419/32.png) [@khuezy](https://community.fly.io/u/khuezy)\
**Post date:** [October 1, 2024, 6:11pm UTC](https://community.fly.io/t/nextjs-app-should-i-use-nginx-in-front-of-it/22084/4 "2024-10-01T18:11:10Z")

</div>

> [@Bonadio](#):
>
> I usually run it behind an Nginx reverse proxy to avoid exposing Node.js directly to the internet.

I was confused by this.  
You do not need nginx in front of your app. Fly will expose your via your fly.toml config: [App configuration (fly.toml) · Fly Docs](https://fly.io/docs/reference/configuration/#the-http_service-section)

When you `fly launch`, it should auto detect your nextjs app and auto config most things.
