I'm building nginx for reverse_proxy with Spring and Docker
Here is my configuration.
nginx.conf
user proxy;
worker_processes auto;
error_log logs/error.log;
error_log logs/error.log notice;
error_log logs/error.log info;
pid logs/nginx.pid;
events {
worker_connections 1024;
}
http {
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 logs/access.log main;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
include mime.types;
default_type application/octet-stream;
include /home/wertkey/nginx/conf/conf.d/*.conf;
client_max_body_size 200M;
client_header_buffer_size 48k;
server {
listen 7070 default_server;
listen [::]:7070 default_server;
server_name _;
root /usr/share/nginx/html;
location / {
}
error_page 404 /404.html;
location = /404.html {
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
}
}
conf.d/default.conf
server {
listen 7070;
server_name something.com;
proxy_connect_timeout 900s;
proxy_send_timeout 900s;
proxy_read_timeout 900s;
send_timeout 900s;
location ^~ /editor/ {
proxy_pass http://localhost:8081;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $host;
rewrite ^/editor/(/.*)$ $1 break;
}
}
docker
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
a6a6a98a25a9 editor "/bin/sh -c /usr/l..." 8 minutes ago Up 8 minutes 0.0.0.0:8081->8080/tcp editor
My spring server is running at 7070 port. I want to be this way.
- request something.com:7070/api
- nginx proxy_pass to 8081
- and docker 8081 -> 8080
But response always return 502 Bad Gateway
What am i missing?