端口80上的heroku + nginx
问题描述:
即时通讯尝试在heroku免费环境中启动一个nginx服务器。我准备好了任何说明和教程,但我没有得到它的运行。端口80上的heroku + 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浏览器上拒绝了连接。
如果我通过测功机我越来越原木
State changed from starting to crashed
我迪诺
web: bin/start-nginx
我nginx.config.erb的Procfile
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;
}
}
}
我还错误消息nginx的开始将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/{
autoindex on;
}
}
}
您是否尝试过不强迫端口为80?我不更改端口,因为Heroku设置它。 “每个Web进程都只是绑定到一个端口,并监听进入该端口的请求,绑定的端口由Heroku指定为PORT环境变量。” - https://devcenter.heroku.com/articles/runtime-principles – adibble
是的,我在努力。 Heroku用一个“随机”端口启动nginx,但我也没有通过浏览器进行响应。正如我读到的,如果我将端口设置为80,他们应该从端口80或端口设置环境启动。 – moohkooh