Veran estoy intentando usar este builpack para poder utilizar NGINX en mi aplicación de heroku, pero no se mucho sobre como configurar nginx. Y solo me base en algunos ejemplos pero no me funciona el archivo nginx.conf.erb
correctamente.
Recientemente modifique mi archivo nginx.conf.erb
y ahora me muestra el error 404 y me nuestra la pagina de error de heroku no such app.
Este es mi archivo nginx.conf.erb
daemon off;
#Heroku dynos have at least 4 cores.
worker_processes <%= ENV['NGINX_WORKERS'] || 8 %>;
events {
use epoll;
multi_accept on;
accept_mutex on;
worker_connections <%= ENV['NGINX_WORKER_CONNECTIONS'] || 10000 %>;
}
http {
charset utf-8;
gzip on;
gzip_comp_level 9;
gzip_min_length 512;
gzip_vary on;
gzip_buffers 16 8k;
gzip_proxied any;
gzip_types
application/atom+xml
application/javascript
application/x-javascript
application/json
application/rss+xml
application/xml+rss
application/vnd.ms-fontobject
application/x-font-ttf
application/x-web-app-manifest+json
application/xhtml+xml
application/xml
font/opentype
image/svg+xml
image/x-icon
text/css
text/plain
text/javascript
text/x-component;
gzip_disable "MSIE [1-6]\.";
server_tokens off;
client_body_buffer_size 128k;
client_header_buffer_size 1k;
large_client_header_buffers 4 8k;
output_buffers 1 32k;
postpone_output 1460;
log_format l2met 'measure#nginx.service=$request_time request_id=$http_x_request_id';
access_log <%= ENV['NGINX_ACCESS_LOG_PATH'] || 'logs/nginx/access.log' %> l2met;
error_log <%= ENV['NGINX_ERROR_LOG_PATH'] || 'logs/nginx/error.log' %>;
log_not_found on;
include mime.types;
default_type application/octet-stream;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
types_hash_max_size 2048;
client_max_body_size 20M;
#Must read the body in 5 seconds.
client_body_timeout 5;
resolver 1.1.1.1 1.0.0.1 8.8.8.8 8.8.4.4 208.67.222.222 208.67.220.220 valid=60s;
resolver_timeout 2s;
upstream app_server {
server nginxapp.herokuapp.com:443;
server 127.0.0.1:<%= ENV["PORT"] %> backup;
}
proxy_ssl_server_name on;
proxy_cache_path /tmp/nginx levels=1:2 keys_zone=nginxapp:10m inactive=60m;
proxy_cache_key "$scheme$request_method$host$request_uri";
server {
gzip on;
gzip_comp_level 9;
gzip_min_length 512;
gzip_vary on;
gzip_buffers 16 8k;
gzip_proxied any;
gzip_disable "MSIE [1-6]\.";
listen <%= ENV["PORT"] %>;
server_name _;
keepalive_timeout 65;
keepalive_requests 100000;
charset utf-8;
root /public;
location / {
set $upstream_app app_server;
proxy_cache nginxapp;
proxy_http_version 1.1;
proxy_cache_bypass $http_cache_control;
add_header X-Proxy-Cache $upstream_cache_status;
proxy_ssl_name nginxapp.herokuapp.com;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Host $host;
proxy_redirect off;
proxy_pass https://$upstream_app;
}
location = /favicon.ico {
log_not_found off;
access_log off;
}
location = /robots.txt {
log_not_found off;
access_log off;
}
location ~* \.(?:css(\.map)?|js(\.map)?|jpe?g|png|gif|ico|cur|heic|webp|tiff?|mp3|m4a|aac|ogg|midi?|wav|mp4|mov|webm|mpe?g|avi|ogv|flv|wmv)$ {
expires 1y;
access_log off;
}
location ~* \.(?:svgz?|ttf|ttc|otf|eot|woff2?)$ {
add_header Access-Control-Allow-Origin "*";
expires 1y;
access_log off;
}
}
}
Y este es mi archivo Procfile para heroku
web: start-nginx-solo node app.js
listen <%= ENV['PORT'] %>