无法获得Heroku& Nginx重定向http请求 - > HTTP

时间:2018-01-30 23:46:53

标签: nginx heroku heroku-toolbelt

我正在使用heroku/nodejshttps://github.com/heroku/heroku-buildpack-nginx.git构建包。

我已经创建了所需的/app/congig/nginx.conf.rb文件,我在构建日志中看到了这一点,`

我在heroku logs输出中看到了这一点:Starting process with command 'bin/start-nginx npm run start'

所以我知道nginx正在运行。但是当我向应用程序发出请求时,我还会在响应标头中看到Server: Cowboy。所以我不知道为什么我的配置会完全绕过NGINX并从牛仔服务呢?

这是我的nginx.conf.rb:



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 debug;
	error_log stderr info;

	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 _;

		keepalive_timeout 5;

    root   /app/build;

		location / {
			proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
			proxy_set_header Host $http_host;
      proxy_redirect off;
			if ($http_x_forwarded_proto != 'https') {
        rewrite ^ https://$host$request_uri? permanent;
      }

			proxy_pass app_server;
		}
	}
}
&#13;
&#13;
&#13;

此外..我还没有找到error.log和access.log文件的位置!我甚至尝试将这些内容设置为/var/log/access|error.log和nope ..当我使用heroku run -a app-name bash时,他们在服务器上的位置并不存在!

很遗憾如何让这个工作......请帮助。

1 个答案:

答案 0 :(得分:2)

显然是nginx&#34; buildpack&#34;要求您在SELECT * FROM A_history WHERE valid_from BETWEEN [reporting interval] OR valid_to BETWEEN [reporting interval]之前触摸文件,然后才能启动nginx ......

因此,将valid_to添加到我的Node应用程序允许nginx启动并处理重定向。