I want everything starting with /api
to be directed to http://localhost:3007
This is my nginx.conf
user nginx;
worker_processes 1;
daemon off;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
server {
listen 80;
server_name localhost;
location / {
root /usr/html;
index index.html index.htm;
}
location /api {
proxy_pass http://localhost:3007;
proxy_read_timeout 5m;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
include servers/*;
}
It works when I run it locally on my mac. But it's not working when I run it in a docker-container.
This is my docker-file:
FROM smebberson/alpine-nginx:latest
COPY /dist /usr/html/
COPY nginx.conf /etc/nginx/nginx.conf
This is my docker-compose:
version: "2"
services:
web:
build: .
ports:
- "80:80"
The error I'm getting from nginx:
2017/06/28 13:06:51 [error] 200#0: *9 connect() failed (111: Connection refused) while connecting to upstream, client: 172.19.0.1, server: localhost, request: "GET /api HTTP/1.1", upstream: "http://127.0.0.1:3007/api", host: "localhost"