Docker Community Forums

Share and learn in the Docker community.

Cannot proxy_pass to localhost


(Bmq928) #1

I’m a beginner to docker and nginx.
I have a simple nodejs app run in host

Blockquote
const express = require(‘express’)
const app = express()
app.use(’/’, (req, res) => res.send(‘success’))
app.listen(3000, () => console.log(‘started’))

My Dockerfile

Blockquote
FROM nginx
RUN rm /etc/nginx/conf.d/default.conf
ADD ./config /etc/nginx/conf.d
ADD ./static /var/www/static
EXPOSE 80

nginx.config

Blockquote
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name localhost;
location / {
root /var/www/static/;
index success.html;
}
location = /google/ {
proxy_pass http://google.com/;
}
location /app/ {
proxy_pass http://localhost:3000/;
}
}

The config proxy_pass to google worked but not the /app/
I use ubuntu 18.04 , Docker ce for linux
Please help me solve this problem.
Thank u.
(Sorry my bad English)