Skip to content

Instantly share code, notes, and snippets.

@asfo
Created March 7, 2018 03:55
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save asfo/1ba56caede88d87c76b53d6afaae52d2 to your computer and use it in GitHub Desktop.
Save asfo/1ba56caede88d87c76b53d6afaae52d2 to your computer and use it in GitHub Desktop.
Configuración de Nginx para Angular
worker_processes 4;
events
{
worker_connections 1024;
}
http
{
include blockips.conf;
# Si tienes SSL descomenta estas líneas para la redirección forzada a HTTPS
#server
#{
# listen 80;
# return 301 https://$host$request_uri;
#}
server
{
server_tokens off;
# Si tienes SSL descomenta esta líneas
# ssl on;
server_name tudominio.com;
root /var/www/html/angular;
index index.html;
# Si tienes SSL descomenta estas líneas
# listen 443 ssl http2;
include mime.types;
default_type application/octet-stream;
sendfile on;
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
gzip on;
gzip_disable "msie6";
gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
# Si tienes SSL descomenta estas líneas
# ssl_certificate /etc/nginx/ssl/server.crt;
# ssl_certificate_key /etc/nginx/ssl/server.key;
location ~ \.css
{
add_header Content-Type text/css;
}
location ~ \.js
{
add_header Content-Type application/javascript;
}
location /
{
expires -1;
add_header Pragma "no-cache";
add_header Cache-Control "no-store, no-cache, must-revalidate, post-check=0, pre-check=0";
try_files $uri $uri/ /index.html;
}
location ~* \.(?:manifest|appcache|html?|xml|json)$
{
expires -1;
}
location ~* \.(?:jpg|jpeg|gif|png|ico|cur|gz|svg|svgz|mp4|ogg|ogv|webm|htc)$
{
expires 1M;
access_log off;
add_header Cache-Control "public";
}
location ~* \.(?:css|js)$
{
expires 1d;
access_log off;
add_header Cache-Control "public";
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment