I would like to rewrite the URL in a reverse proxy so in my case I would like to change url like below, I ran some containers so they callable now but with port and localhost I add a new container with nginx revers proxy and with this I would like to revert my url but I don't know how should I define nginx.conf in this path /etc/nginx/nginx.conf:
when I enter some url it should call like below:
http://addons.example.com => http://localhost:89
http://my.example.com => http://localhost
http://phpmyadmin.example.com => http://localhost:5054
due to my config I got this error in docker log when I call http://addons.project.com/test.php:
production_nginx | 2022/02/23 13:49:27 [error] 31#31: *1 open() "/etc/nginx/html/test.php" failed (2: No such file or directory), client: 172.25.0.1, server: my.project.com, request: "GET /test.php HTTP/1.1", host: "addons.project.com"
this is my config of nginx:
events {
}
http {
client_max_body_size 20m;
proxy_cache_path /etc/nginx/cache keys_zone=one:500m max_size=1000m;
server {
server_name my.example.com;
location /my.example.com/ {
proxy_pass http://127.0.0.1:80;
rewrite ^/my.example.com(.*)$ $1;
}
location /addons.example.com/ {
proxy_pass http://127.0.0.1:89;
rewrite ^/addons.example.com(.*)$ $1;
}
}
}
Thanks in advance