ubuntu – Reverse proxy and rewrite URL in NGINX

I want to redirect requests to our internal repository servers without edit repository addresses in package manager’s configuration. Here is the scenario:

Add internal IP (NGINX Server) address to hosts file as “ubuntu.com” or any other domain in each server.
Reverse proxy http or https requests which wants reach “ubuntu.com” or other domains to repository server address with different port as http request.
Would you please comment some samples for this scenario?

I can do reverse proxy, but I need some samples to rewrite URL if needed and replace domain with repository server address.

Read more here: Source link