title: heroku + nginx on port 80
body: <p>im trying to start a nginx server on heroku free environmnent. I ready any how-tos and tutorial, but i dont get it running.</p>
  
  <p>First of all, i would like to start nginx as default web-server on Port 80. Afterwards i would like configure nginx as proxy for the underline express server (other heroku instance). 
  For 4 days i trying to start only nginx on my heroku instance. I always getting the exception that not permitted to start on port 80. 
  I forked the nginx-buildback (<a href="https://github.com/moohkooh/nginx-buildpack" rel="nofollow noreferrer">https://github.com/moohkooh/nginx-buildpack</a>) from (<a href="https://github.com/benmurden/nginx-pagespeed-buildpack" rel="nofollow noreferrer">https://github.com/benmurden/nginx-pagespeed-buildpack</a>) to adjust some configuration. If i run nginx via heroku bash on port 2555, nginx is starting, but i get connection refused on web-browser.</p>
  
  <p>If i starting nginx via Dyno i getting error message on logs</p>
  
  <pre><code>  State changed from starting to crashed
  </code></pre>
  
  <p>the Procfile of my Dyno</p>
  
  <pre><code>  web: bin/start-nginx
  </code></pre>
  
  <p>My nginx.config.erb</p>
  
  <pre><code> daemon off;
   #Heroku dynos have at least 4 cores.
   worker_processes &lt;%= ENV['NGINX_WORKERS'] || 4 %&gt;;
  
   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;
  
       server {
           listen &lt;%= ENV['PORT'] %&gt;;
           server_name _; 
           keepalive_timeout 5; 
           root /app/www;
           index index.html;
  
           location / {
               autoindex on; 
           }
       }
  }
  </code></pre>
  
  <p>I also set PORT variable to 80 </p>
  
  <pre><code> heroku config:get PORT
   80
  </code></pre>
  
  <p>Some other configuration:</p>
  
  <pre><code> heroku config:get NGINX_WORKERS
   8
   heroku buildpacks
   https://github.com/heroku/heroku-buildpack-multi.git
   heroku stack
   cedar-14
  </code></pre>
  
  <p>My .buildpack file</p>
  
  <pre><code>https://github.com/moohkooh/nginx-buildpack
  https://codon-buildpacks.s3.amazonaws.com/buildpacks/heroku/ruby.tgz
  </code></pre>
  
  <p>I also have the guess, that heroku dont use my variable that i set to 80. Whats wrong? Big thanks for anyone. </p>
  
  <p>Btw: my express server running without any error on port 1000 (for test i start it also on port 80 without any errors)</p>