ryandotsmith / nginx-buildpack

Run NGINX in front of your app server on Heroku
456 stars 783 forks source link

nginx proxy_pass blocks the port #76

Open bbreton3 opened 6 years ago

bbreton3 commented 6 years ago

I am trying to host the Tensorboard on a Heroku instance, and to secure it, I have added nginx using the nginx-buildpack in front of it. The idea is that Tensorboard will create the app on port 6006, and Nginx will redirect this port to the external port provided by Heroku $Port.

When I start the app, I have the following error:

TensorBoard attempted to bind to port 6006, but it was already in use

My config files are as follows:

Procfile

web: bin/start-nginx tensorboard --logdir="/app/" --host=http://127.0.0.1 --port=6006

config/nginx.conf.erb

daemon off;
#Heroku dynos have at least 4 cores.
worker_processes <%= ENV['NGINX_WORKERS'] || 4 %>;

events {
    use epoll;
    accept_mutex on;
    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 logs/nginx/access.log l2met;
        error_log 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 app_server {
        #   server unix:/tmp/nginx.socket fail_timeout=0;
        #}

        server {
            listen <%= ENV["PORT"] %>;
            server_name http://127.0.0.1;
            keepalive_timeout 5;
            root   /app;
            port_in_redirect off;
        #index  index.html index.htm;

        location = / {
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header Host $http_host;
            proxy_redirect off;
            proxy_pass http://127.0.0.1:6006;
        }
    }
}