将 htaccess 添加到 Ghost 项目
Add htaccess to a Ghost project
我正在尝试向我的 ghost 项目添加 .htaccess 以启用 gzip 压缩,我在 Nginx Ubuntu 16 和 Ghost-cli 中为我的项目提供服务,我看到 sites-avalable 生成了一个代理重定向到在 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 文件添加到我的项目中
首先,在你想要的地方添加你的.htaccess。假设它在 /var/projects/projectName/.htaccess
在位置/{ => 你必须添加
auth_basic "Restricted Content";
auth_basic_user_file /var/projects/projectName/.htaccess;
希望对您有所帮助
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。
我正在尝试向我的 ghost 项目添加 .htaccess 以启用 gzip 压缩,我在 Nginx Ubuntu 16 和 Ghost-cli 中为我的项目提供服务,我看到 sites-avalable 生成了一个代理重定向到在 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 文件添加到我的项目中
首先,在你想要的地方添加你的.htaccess。假设它在 /var/projects/projectName/.htaccess
在位置/{ => 你必须添加
auth_basic "Restricted Content";
auth_basic_user_file /var/projects/projectName/.htaccess;
希望对您有所帮助
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。