I created Vertx application which contains 2 verticles. 1 is running on port 8888 and the other is running on 8881.
I am trying to deploy the application on Elastic beanstalk. But I'm getting error 502 Bad Gateway.
Here's the config file nginx place at .ebextensions/nginx/nginx.conf
user nginx;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
worker_processes auto;
worker_rlimit_nofile 33282;
events {
worker_connections 1024;
}
http {
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"';
include conf.d/*.conf;
map $http_upgrade $connection_upgrade {
default "upgrade";
}
server {
listen 5000;
root /var/app/current/public;
location / {
}
location /api {
proxy_pass http://127.0.0.1:8888;
proxy_http_version 1.1;
proxy_set_header Connection $connection_upgrade;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
location /api2 {
proxy_pass http://127.0.0.1:8881;
proxy_http_version 1.1;
proxy_set_header Connection $connection_upgrade;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
access_log /var/log/nginx/access.log main;
client_header_timeout 60;
client_body_timeout 60;
keepalive_timeout 60;
gzip off;
gzip_comp_level 4;
# Include the Elastic Beanstalk generated locations
include conf.d/elasticbeanstalk/01_static.conf;
include conf.d/elasticbeanstalk/healthd.conf;
}
}
Here's the CodeBuild buildspec.yml file:
version: 0.2
phases:
install:
runtime-versions:
java: corretto11
build:
commands:
- echo Build started on 'date'
- gradle bootJar
post_build:
commands:
- echo Build completed on 'date'
- ls build/libs
- mv build/libs/*.jar app.jar
- ls
artifacts:
files:
- app.jar
- .ebextensions/**/*
I have installed nginx on my local machine and with the above configuration it is working fine.
Did I miss something?