linux - run nginx in docker with another application -


i have application needs serve on port :5000

here's dockerfile

from ubuntu:14.04 run apt-get update run apt-get install -y nginx add ./nginx.conf /etc/nginx/sites-available/default run service nginx restart  run go github.com/a/mycmd  expose 5000 

and run

sudo docker run --publish 5000:5000 --rm app /go/bin/mycmd 

and here's nginx config file:

limit_req_zone $binary_remote_addr zone=limit:10m rate=2r/s;  server {     listen 80;      set_real_ip_from 0.0.0.0/0;     real_ip_header x-forwarded-for;     real_ip_recursive on;     server_name 123.13.13.13 example.com;      location / {         proxy_read_timeout 3000s;         proxy_set_header host $host;         proxy_set_header x-real-ip $remote_addr;         proxy_set_header x-forwarded-for $remote_addr;         proxy_pass http://127.0.0.1:5000;         limit_req zone=limit burst=5 nodelay;     } } 

then expect redirect traffic webserver (port 80) app port 5000, seems nginx doesn't reverse proxy correctly. traffic not directed app.

how set nginx , app in same container can use reverse proxy?

thanks!

you mention in nginx config:

proxy_pass http://127.0.0.1:8000; 

but want redirect expose'd port 5000.

proxy_pass http://127.0.0.1:5000; 

if typo, make sure publish 80 , host port (ot using container ip address directly.

don't forget that, if areusing vm, might have port-forward published port: see "connect service running inside docker container outside"


Comments

Popular posts from this blog

Hatching array of circles in AutoCAD using c# -

ios - UITEXTFIELD InputView Uipicker not working in swift -

Python Pig Latin Translator -