nginx

Redirect traffic to another url

A nginx configuration to redirect traffic from localhost:8080 to https://fooserver:9200/
Here how to start a docker container with that configuration stored into a /conf/nginx.conf file :
docker run --name nginx-redirect-traffic -p 8080:8080 -v /conf/nginx.conf:/etc/nginx/nginx.conf:ro -d nginx:latest

user  nginx;
worker_processes  1;
 
error_log  /var/log/nginx/error.log warn;
pid        /var/run/nginx.pid;
 
 
events {
    # max concurrent requests
    worker_connections  1024;
}
 
 
http {
    include       /etc/nginx/mime.types;
    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;
    #tcp_nopush     on;
 
    keepalive_timeout  65;
 
    #gzip  on;
 
    include /etc/nginx/conf.d/*.conf;
 
   server {
     # port and host that nginx listens to 
     listen        8080;
     server_name   localhost;
 
     location / {
       # url where nginx must redirect the incomming requests
       proxy_pass  https://fooserver:9200/;
     }
 
  }
 
}
Ce contenu a été publié dans Non classé. Vous pouvez le mettre en favoris avec ce permalien.

Laisser un commentaire

Votre adresse de messagerie ne sera pas publiée. Les champs obligatoires sont indiqués avec *