nginx的配置
worker_processes 1;
#pid logs/nginx.pid;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
gzip on;
gzip_types text/plain application/x-javascript application/javascript text/css application/xml text/javascript application/x-httpd-php image/jpeg image/gif image/png;
gzip_proxied any;
gzip_vary on;
gzip_min_length 5k;
gzip_comp_level 6;
gzip_buffers 16 8k;
sendfile on;
proxy_cache_path /var/nginx/cache levels=1:2 keys_zone=my_cache:10m max_size=10g inactive=60m use_temp_path=off;
keepalive_timeout 65;
server {
listen 80;
server_name blog.zzzyuan.cn;
return 301 https://$server_name$request_uri;
}
server{
listen 443 ssl;
server_name blog.zzzyuan.cn;
ssl_certificate /usr/local/ssl/4143414_blog.zzzyuan.cn.pem;
ssl_certificate_key /usr/local/ssl/4143414_blog.zzzyuan.cn.key;
ssl_session_timeout 5m;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE;
ssl_prefer_server_ciphers on;
location / {
root /var/easy;
index index.html;
try_files $uri $uri/ /index.html;
}
location ~* ^.+\.(eot|ttf|otf|woff|svg)$ {
access_log off;
expires max;
}
location ~* ^.+\.(ico|gif|jpg|jpeg|png)$ {
access_log off;
expires 2d;
}
location ~* ^.+\.(css|js|txt|xml|swf|wav)$ {
access_log off;
expires 24h;
}
}
server {
listen 443 ssl;
server_name ***.******.cn;
root html;
index index.html index.htm;
ssl_certificate /usr/local/ssl/5099983_api.zzzyuan.cn.pem;
ssl_certificate_key /usr/local/ssl/5099983_api.zzzyuan.cn.key;
ssl_session_cache shared:SSL:1m;
ssl_session_timeout 5m;
ssl_ciphers HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on;
location /api/ {
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://localhost:8081/api/;
}
}
server {
listen 80;
server_name **.**y***.cn;
return 301 https://$host$request_uri;
}
}
vue项目中的配置
configureWebpack: ()=> {
if (process.env.NODE_ENV === 'production') {
return {
plugins: [
new CompressionPlugin({
filename: '[path].gz[query]',
algorithm: 'gzip',
test: /\.js$|\.html$|\.css$/, // 需要压缩的文件类型
threshold: 1024, // 归档需要进行压缩的文件大小最小值,我这个是10K以上的进行压缩
deleteOriginalAssets: false // 是否删除原文件
})
],
}
}
},
打包后的内容