I have an umbrella application in elixir with two app endpoints, one for API, and another one for IoT. I am using a reverse proxy to serve the application as there are two endpoints running on different ports.
The build pack being used for the reverse proxy is: https://github.com/heroku/heroku-buildpack-nginx
This is my Nginx configuration file.
daemon off;
worker_processes <%= ENV['NGINX_WORKERS'] || 4 %>;
events {
use epoll;
accept_mutex on;
worker_connections <%= ENV['NGINX_WORKER_CONNECTIONS'] || 1024 %>;
}
http {
gzip on;
gzip_comp_level 2;
gzip_min_length 512;
server_tokens off;
log_format l2met 'measure#nginx.service=$request_time request_id=$http_x_request_id';
access_log <%= ENV['NGINX_ACCESS_LOG_PATH'] || 'logs/nginx/access.log' %> l2met;
error_log <%= ENV['NGINX_ERROR_LOG_PATH'] || 'logs/nginx/error.log' %>;
include mime.types;
default_type application/octet-stream;
sendfile on;
#Must read the body in 5 seconds.
client_body_timeout 5;
upstream api {
server 127.0.0.1:4000 max_fails=5 fail_timeout=60s;
}
upstream iot {
server 127.0.0.1:4001 max_fails=5 fail_timeout=60s;
}
server {
listen <%= ENV["PORT"] %>;
server_name 0.0.0.0;
keepalive_timeout 5;
location /api {
allow all;
# Proxy Headers
proxy_http_version 1.1;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header X-Cluster-Client-Ip $remote_addr;
# The Important Websocket Bits!
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_pass http://api;
}
location /iot {
allow all;
# Proxy Headers
proxy_http_version 1.1;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header X-Cluster-Client-Ip $remote_addr;
# The Important Websocket Bits!
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_pass http://iot;
}
}
}
Apparently, the buildpack expects a file /tmp/app-initialized
to be written once the app is initialized.
The command I am using is mix phx.server
to start the umbrella.
What would be the right way to write this file(/tmp/app-initialized
) after app initialization in the phoenix umbrella.