欢迎光临
我们一直在努力

端口80上的heroku nginx

本站教程收集整理的这篇文章主要介绍了端口80上的heroku nginx,本站教程本站觉得挺不错的,现在分享给大家,也给大家做个参考。

即时尝试在Heroku free environmnent上启动Nginx服务器.我准备了任何方法和教程,但我没有让它运行.

首先,我想在端口80上启动Nginx作为默认的Web服务器.之后我想配置Nginx作为下划线express服务器(其他heroku实例)的代理.
4天我试图在我的heroku实例上只启动Nginx.我总是得到不允许在端口80上启动的异常.
我从(https://github.com/benmurden/nginx-pagespeed-buildpack)分叉了Nginx-buildBACk(https://github.com/moohkooh/nginx-buildpack)来调整一些配置.如果我通过端口2555上的heroku bash运行Nginx,Nginx正在启动,但我在Web浏览器上拒绝连接.

如果我通过Dyno启动Nginx我在日志上收到错误消息

  State changed from starTing to crashed

我的Dyno的procfile

  web: bin/start-Nginx

我的Nginx.config.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;

     server {
         listen <%= ENV['PORT'] %>;
         server_name _; 
         keepalive_timeout 5; 
         root /app/www;
         index index.html;

         LOCATIOn / {
             autoindex on; 
         }
     }
}

我还将PORT变量设置为80

 heroku config:get PORT
 80

其他一些配置:

 heroku config:get Nginx_WORKERS
 8
 heroku buildpacks
 https://github.com/heroku/heroku-buildpack-multi.git
 heroku stack
 cedar-14

我的.buildpack文件

https://github.com/moohkooh/Nginx-buildpack
https://codon-buildpacks.s3.amazonaws.com/buildpacks/heroku/ruby.tgz

我也有猜测,heroku不使用我设置为80的变量.怎么回事?非常感谢任何人.

顺便说一句:我的快递服务器在端口1000上没有任何错误运行(对于测试我也在端口80上启动它而没有任何错误)

解决方法:

我用这个配置解决了我的问题.

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

pid Nginx.pid;

events { 
    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;

    server {
        listen <%= ENV['PORT'] %>;
        server_name localhost;
        port_in_redirect off;
        keepalive_timeout 5; 
        root /app/www; 
        index index.html;

        LOCATIOn 便宜香港vps / {
            autoindex on; 
        }
    }
}

本站总结

以上是本站教程为你收集整理的端口80上的heroku nginx全部内容,希望文章能够帮你解决端口80上的heroku nginx所遇到的程序开发问题。

如果觉得本站教程网站内容还不错,欢迎将本站教程推荐给好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。

赞(0)
【声明】:本博客不参与任何交易,也非中介,仅记录个人感兴趣的主机测评结果和优惠活动,内容均不作直接、间接、法定、约定的保证。访问本博客请务必遵守有关互联网的相关法律、规定与规则。一旦您访问本博客,即表示您已经知晓并接受了此声明通告。