Redirect with core/<nginx or htpd>

community

#1

Dear Guys,

I must use core pkgs of Habitat, but when I use package core/nginx, I can not make simple redirect via hab config apply. How I can help and rewrite package core/nginx, for include redirect. Tnx.

Some improvements:

worker_processes {{cfg.worker_processes}};
daemon off;
events {
worker_connections {{cfg.events.worker_connections}};
}
http {
include mime.types;
default_type application/octet-stream;
sendfile {{cfg.http.sendfile}};
tcp_nopush {{cfg.http.tcp_nopush}};
tcp_nodelay {{cfg.http.tcp_nodelay}};
keepalive_timeout {{cfg.http.keepalive_timeout}};
gzip on;
gzip_vary on;
gzip_min_length 10240;
gzip_proxied expired no-cache no-store private auth;
gzip_types text/plain text/css text/xml text/javascript application/x-javascript application/xml;
gzip_disable “MSIE [1-6].”;

{{#if cfg.redirector_https ~}}
server {
    listen       {{cfg.http.listen.port}} default_server;
    listen       [::]:{{cfg.http.listen.port}} default_server;
    server_name  _;
    return 301 https://$host$request_uri;
}
{{#if cfg.redirector_htpp ~}}
server {
    listen       {{cfg.http.listen.port}} default_server;
    listen       [::]:{{cfg.http.listen.port}} default_server;
    server_name  _;
    return 301 http://$host$request_uri;
}
{{#if cfg.redirector_https_port ~}}
server {
    listen       {{cfg.http.listen.port}} default_server;
    listen       [::]:{{cfg.http.listen.port}} default_server;
    server_name  _;
    return 301 https://$host:{{cfg.network.https_port}}$request_uri;
}
{{#if cfg.redirector_htpp_port ~}}
server {
    listen       {{cfg.http.listen.port}} default_server;
    listen       [::]:{{cfg.http.listen.port}} default_server;
    server_name  _;
    return 301 http://$host:{{cfg.network.http_port}}$request_uri;
}
{{else}}
server {
    listen       {{cfg.http.listen.port}};
    server_name  localhost;

    location / {
        root   {{pkg.svc_data_path}};
        index  index.html index.htm;
}

}
{{/if ~}}
}

What do you think about it?