将htaccess添加到Ghost项目

时间:2018-06-11 03:50:11

标签: node.js .htaccess nginx digital-ocean ghost

我正在尝试向我的ghost项目添加.htaccess以启用gzip压缩,我在Nginx Ubuntu 16和Ghost-cli中服务我的项目,我看到可用的网站生成一个重定向到节点的代理在localhost:2368上运行,这是配置

server {

server_name latribu.mx www.latribu.mx;
root /var/www/latribu.mx/html/system/nginx-root;

location / {
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto $scheme;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header Host $http_host;
    proxy_pass http://127.0.0.1:2368;

}

location ~ /.well-known {
    allow all;
}

client_max_body_size 50m;

listen [::]:443 ssl; # managed by Certbot
listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/latribu.mx/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/latribu.mx/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot

}

server {
if ($host = latribu.mx) {
    return 301 https://$host$request_uri;
} # managed by Certbot

if ($host = www.latribu.mx) {
    return 301 https://$host$request_uri;
} # managed by Certbot

listen 80;
listen [::]:80;

server_name latribu.mx www.latribu.mx;
return 404; # managed by Certbot
}

如何将.htaccess文件添加到我的项目

2 个答案:

答案 0 :(得分:0)

首先,将您的.htaccess添加到您想要的位置。让我们在/var/projects/projectName/.htaccess中说出来

位置/ {=>你必须添加

std::vector::end

希望这是有帮助的

答案 1 :(得分:0)

Nginx不支持Apache之类的.htaccess文件。如果要使用Nginx启用GZip,请打开/etc/nginx/nginx.conf。向下滚动到GZip设置部分,然后添加以下行。

gzip on;

gzip_vary on;
gzip_proxied any;
gzip_comp_level 6;
gzip_buffers 16 8k;
gzip_http_version 1.1;
gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;

然后使用service nginx restart重新启动Nginx。