Skip to content

Instantly share code, notes, and snippets.

@developertugrul
Created August 4, 2023 12:29
Show Gist options
  • Save developertugrul/85c6c2749eb8c6b9fc56fb595fc9a809 to your computer and use it in GitHub Desktop.
Save developertugrul/85c6c2749eb8c6b9fc56fb595fc9a809 to your computer and use it in GitHub Desktop.
nginx.conf
# 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