Quantcast
Channel: Nginx Forum - How to...
Viewing all articles
Browse latest Browse all 4759

NginX Load Balancing with Podman Compose

$
0
0
For those that may not know, podman is a container system that can run rootless. Podman-compose, Podman's version of docker-compose, requires that all ports be unique since they use a shared network. Si, I have several containers running services at different ports. I then configured nginx to have the services to be load balanced listed in the upstream block with their ports. I then have nginx listening at port 80. In the podman compose, I have the Nginx service listing at exposed port 8090.
When I run this scenario, if I go to http://localhost:8090, Nginx routes to port 80 for the upstream servers, but they are not available at port 80, so I get an HTTP 302 Found error. If I change that URL in the browser, from port 80 to 8090, that URL works. I cannot seem to find a way to tell Nginx that when it modifies the URL for the upstream servers, it should make them port 8090 externally, assuming that is what needs to be done.

This is my nginx.conf file:

worker_processes 1;

events {
worker_connections 1024;
}

http {
include mime.types;
default_type application/octet-stream;

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

log_format download '$remote_addr - $remote_user [$time_local] '
'"$request" $status $bytes_sent '
'"$http_referer" "$http_user_agent" '
'"$http_range" "$sent_http_content_range"';

client_header_timeout 3m;
client_body_timeout 3m;
send_timeout 3m;

client_header_buffer_size 1k;
large_client_header_buffers 4 4k;

gzip on;
gzip_min_length 1100;
gzip_buffers 4 8k;
gzip_types text/plain;

output_buffers 1 32k;
postpone_output 1460;

sendfile on;
tcp_nopush on;

tcp_nodelay on;

keepalive_timeout 75 20;


upstream docker_nginx {
server solr1:8981;
server solr2:8982;
server solr3:8983;
}

server {
listen 80;

access_log /var/log/nginx/access.log main;
error_log /var/log/nginx/error.log debug;
rewrite_log on;

server_name localhost;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
client_max_body_size 10m;
client_body_buffer_size 128k;

proxy_connect_timeout 90;
proxy_send_timeout 90;
proxy_read_timeout 90;

proxy_buffer_size 4k;
proxy_buffers 4 32k;
proxy_busy_buffers_size 64k;
proxy_temp_file_write_size 64k;

location / {
proxy_pass http://docker_nginx;

}

location = /wpad.dat {
access_log off;
return 404;
}
}
}

Any help will be very much appreciated.

Thanks.

Viewing all articles
Browse latest Browse all 4759

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>