redirect nginx from port to another port and subdirectory nginx

br flag

I have a service running on: http://localhost:49159 I created an nginx docker to forward the service from port 49 to 8080 by the following

user  nginx;
worker_processes  auto;

error_log  /var/log/nginx/error.log notice;
pid        /var/run/;

events {
    worker_connections  1024;

http {
    include mime.types;
    sendfile on;
    upstream aspnetapp {


    server {
    listen       8080;
    autoindex off;
    server_name localhost;
    server_tokens off;

    location / {

so by now, I can forward all the request from http://localhost:49159 to http://localhost:8080

Now, I want to forward all the requests from http://localhost:49159 to http://localhost:8080/service/. so all the requests will be redirected to /service/ subdirectory of 8080.

Preferably, I don't want to change my service config. I hope I can make this change by changing nginx.conf


Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.