Welcome! Log In Create A New Profile

Advanced

Location (proxy_pass) directive-newbie question

Posted by jd2020 
Location (proxy_pass) directive-newbie question
January 29, 2020 04:01AM
Hi. I'm sure this is a recurring topic for newbies (please bear with me!) and I have read the documentation and done a web search for solutions but still can't get this to work.
I am trying to setup nginx as a reverse proxy in a docker setup for a kanboard installation. The docker / kanboard details are less relevant as it is the basic working of the location and proxy_pass directives I need to understand.
I want the following solution:

When using the 'mydomain.com/kb' address, I want 'mydomain.com' to be sent to the proxy (kanboard container). Later, I will add other containers and use other address such as 'mydomain.com/xx'.
The aim then is to remove the trailing 'kb' from the address sent to the proxy.

Here is the relevant section of my nginx.conf:



http {
default_type application/octet-stream;

log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';

access_log /var/log/nginx/access.log main;

sendfile on;
keepalive_timeout 65;

upstream docker-kanboard {
server kanboard:80;
}

server {
server_name mydomain.com;

location = /kb {
proxy_pass http://docker-kanboard/;
rewrite /kb/(.*) $1 break;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Host $server_name;

}
}
}


I'm sure it's something simple, but any help greatly appreciated.
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 318
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready