'Nginx config as a reverse proxy server with swagger

I started learning nginx and would like to use that like a reverse proxy in my pet project. I have a docker-compose file which launch three containers (1 - for .NET Core app, 2 - nginx container and 3 - MS SQL Server container and I will add fourth container for React app). Now all containers are working fine (.NET Core container is open swagger page and nginx container is open welcome page on port 80). But I would like to open swagger page on port 80 and tried to change nginx.conf file for that. After my changing I'm not able to open swagger page and it always returns 404 error. What should I change to make it works in a right way?

nginx.conf

worker_processes  1;

events {
    worker_connections  1024;
}


http {
    # TgBot Reverse Proxy
    include       mime.types;
    default_type  application/octet-stream;

    sendfile        on;
    keepalive_timeout  65;

    server {
        listen       80;
        server_name  localhost;

        location / {
            proxy_pass http://localhost:5000/swagger/index.html;
        }
        
    location /admin {
            proxy_pass http://telegrambot.service:5000/;
            proxy_set_header X-Forwarded-For $remote_addr;
        }

        
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
       
    }
}

docker-compose.yml

version: '3.4'

services:
  telegrambot.service:
    image: ${DOCKER_REGISTRY-}telegrambotservice
    container_name: tgbot-service
    ports:
        - "5000:80" 
    build:
      context: .
      dockerfile: TelegramBot.WebApi/Dockerfile
    depends_on:
        - db

  db:
    image: "mcr.microsoft.com/mssql/server"
    container_name: db-tgbot
    environment:
        SA_PASSWORD: "BkmzRkbitdbx00!"
        ACCEPT_EULA: "Y"       
    ports:
        - "1433:1433"
    volumes:
        - tgbot-db:/var/opt/mssql/    

  nginx:
    image: "nginx"
    container_name: nginx
    ports:
        - "80:80"
    depends_on:
        - telegrambot.service
    volumes:
        - ./TelegramBot.Proxy/nginx.conf:/etc/nginx/nginx.conf

volumes:
  tgbot-db:
  
   


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source