# Supplementary Guide: Using Nginx as API Gateway — Quick Setup & Usage This guide supplements the article [Using Nginx as API Gateway](https://marcospereirajr.com.br/using-nginx-as-api-gateway-7bebb3614e48) by Marcos Pereira. At each step, read the article and run the corresponding commands locally to see how it works yourself. Follow these steps to quickly clone, configure, and run the project locally. --- ## 1. Clone the Repository ```bash git clone https://github.com/marcospereirampj/nginx-api-gateway.git cd nginx-api-gateway ``` --- ## 2. Modify the Root Dockerfile In the root folder, open the **Dockerfile** and add the following line **before** the `EXPOSE` or `CMD` instructions: ```dockerfile RUN mv /etc/nginx/conf.d/default.conf /etc/nginx/conf.d/default.conf.bak ``` ![image](https://hackmd.io/_uploads/HykvJbQzlg.png) This disables the default Nginx server config so your custom gateway config will work properly. --- ## 3. Update `gateway.conf` Replace the content of `gateway.conf` (located in `./conf.d/gateway.conf`) with the following (taken from the article) update and try with as you follow along: ```nginx server { listen 80; server_name localhost; location /api/users { proxy_pass http://users-api:8002; } location /api/products { proxy_pass http://products-api:8001; } } ``` This config proxies `/api/users` and `/api/products` requests to backend services running on the specified ports. --- ## 4. Run the Application Use Docker Compose to build and run the app: ```bash docker compose up --build ```