I am trying to use nginx in a docker container. I created a configuration file that works with / but not with /team/soccer (I need this). In this case it goes to the site that is located on the server that contains the docker machines. Am I missing something? myserver is the name of a docker container that contains the site I need to open. docker_nginx is the name of the docker that contains nginx. All the docker machines are within a docker network. The next is the nginx.conf file:
events {
worker_connections 1024; # increase if you have lots of clients
accept_mutex off; # "on" if nginx worker_processes > 1
# use epoll; # enable for Linux 2.6+
# use kqueue; # enable for FreeBSD, OSX
}
http {
# proxy_buffering off; <- don't forget to comment out or remove this line.
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Scheme $scheme;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
# proxy_cache_path /var/lib/nginx/cache levels=1:2 keys_zone=one:1000m;
proxy_cache_methods GET HEAD;
proxy_cache_key $host$uri$is_args$args;
proxy_cache_valid 200 10m;
# Do gzip compression with nginx, not the play application
gzip on;
gzip_comp_level 9;
gzip_proxied any;
# This is important if you use Play chunked response as chunked response is only available with HTTP 1.1
proxy_http_version 1.1;
upstream mybackend {
server myserver:9000;
}
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;
keepalive_timeout 65;
index index.html index.htm;
server {
listen docker_nginx:80;
#server_name docker_nginx;
location / {
proxy_buffering off;
proxy_pass http://mybackend;
}
location /team/soccer {
proxy_buffering off;
proxy_pass http://mybackend;
}
# location ~ ^/(assets|webjars)/ {
# # proxy_cache one;
# proxy_cache_key "$host$request_uri";
# proxy_cache_valid 200 30d;
# proxy_cache_valid 301 302 10m;
# proxy_cache_valid 404 1m;
# proxy_pass http://backend;
# }
}
}
0 Answers