Skip to content

Instantly share code, notes, and snippets.

@fcaldarelli
Created August 19, 2023 08:07
Show Gist options
  • Save fcaldarelli/4493556be11d03a881e41c1d975a24ca to your computer and use it in GitHub Desktop.
Save fcaldarelli/4493556be11d03a881e41c1d975a24ca to your computer and use it in GitHub Desktop.
# Define upstream blocks for each microservice
upstream user_service {
server user-service-container-ip:8001; # Replace with the IP address of the user-service container and its actual port
}
upstream product_service {
server product-service-container-ip:8002; # Replace with the IP address of the product-service container and its actual port
}
upstream order_service {
server order-service-container-ip:8003; # Replace with the IP address of the order-service container and its actual port
}
# Main server block to handle incoming requests
server {
listen 80;
server_name api.example.com; # Replace with your actual domain or IP address
location /users {
# Route requests to the user-service
proxy_pass http://user_service;
proxy_set_header Host $host;
}
location /products {
# Route requests to the product-service
proxy_pass http://product_service;
proxy_set_header Host $host;
}
location /orders {
# Route requests to the order-service
proxy_pass http://order_service;
proxy_set_header Host $host;
}
# Add any other API routes and their corresponding services here
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment