docs: fix nginx config and remove dead links

pull/5367/head
Divyansh Singh 4 weeks ago
parent db28226b9a
commit a422b22f3f

@ -292,10 +292,6 @@ You can deploy your VitePress project with [CloudRay](https://cloudray.io/) by f
You can deploy your VitePress project with [Hostinger](https://www.hostinger.com/web-apps-hosting) by following these [instructions](https://www.hostinger.com/support/how-to-deploy-a-nodejs-website-in-hostinger/). While configuring build settings, choose VitePress as the framework and adjust the root directory to `./docs`. You can deploy your VitePress project with [Hostinger](https://www.hostinger.com/web-apps-hosting) by following these [instructions](https://www.hostinger.com/support/how-to-deploy-a-nodejs-website-in-hostinger/). While configuring build settings, choose VitePress as the framework and adjust the root directory to `./docs`.
### Kinsta
You can deploy your VitePress website on [Kinsta](https://kinsta.com/static-site-hosting/) by following these [instructions](https://kinsta.com/docs/vitepress-static-site-example/).
### Stormkit ### Stormkit
You can deploy your VitePress project to [Stormkit](https://www.stormkit.io) by following these [instructions](https://stormkit.io/blog/how-to-deploy-vitepress). You can deploy your VitePress project to [Stormkit](https://www.stormkit.io) by following these [instructions](https://stormkit.io/blog/how-to-deploy-vitepress).
@ -308,46 +304,57 @@ You can deploy your VitePress project to [Stormkit](https://www.stormkit.io) by
npx surge docs/.vitepress/dist npx surge docs/.vitepress/dist
``` ```
### Nginx ### nginx
Here is a example of an Nginx server block configuration. This setup includes gzip compression for common text-based assets, rules for serving your VitePress site's static files with proper caching headers as well as handling `cleanUrls: true`. Here is a example of an nginx server block configuration. This setup includes gzip compression for common text-based assets, rules for serving your VitePress site's static files with proper caching headers as well as handling `cleanUrls: true`.
```nginx ```nginx
server { map $uri $cache_control {
gzip on; ~^/assets/ "public, max-age=31536000, immutable";
gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript; default "no-cache";
}
listen 80; server {
listen 8080;
listen [::]:8080;
server_name _; server_name _;
index index.html;
location / { root /usr/share/nginx/html;
# content location index index.html;
root /app; charset utf-8;
server_tokens off;
# exact matches -> reverse clean urls -> folders -> not found absolute_redirect off;
try_files $uri $uri.html $uri/ =404;
# non existent pages gzip on;
error_page 404 /404.html; gzip_vary on;
gzip_comp_level 5;
gzip_min_length 1024;
gzip_types
application/javascript
application/json
application/manifest+json
image/svg+xml
text/css
text/javascript
text/plain;
add_header Cache-Control $cache_control always;
add_header X-Content-Type-Options "nosniff" always;
add_header X-Frame-Options "SAMEORIGIN" always;
add_header Referrer-Policy "strict-origin-when-cross-origin" always;
# a folder without index.html raises 403 in this setup location / {
error_page 403 /404.html; try_files $uri $uri.html $uri/index.html =404;
}
# adjust caching headers location ~ ^(?<page>.+)/$ {
# files in the assets folder have hashes filenames if (-f $document_root$page.html) {
location ~* ^/assets/ { return 301 $page$is_args$args;
expires 1y;
add_header Cache-Control "public, immutable";
} }
try_files $page/index.html =404;
} }
error_page 404 /404.html;
} }
``` ```
This configuration assumes that your built VitePress site is located in the `/app` directory on your server. Adjust the `root` directive accordingly if your site's files are located elsewhere.
::: warning Do not default to index.html
The try_files resolution must not default to index.html like in other Vue applications. This would result in an invalid page state.
:::
Further information can be found in the [official nginx documentation](https://nginx.org/en/docs/), in these issues [#2837](https://github.com/vuejs/vitepress/discussions/2837), [#3235](https://github.com/vuejs/vitepress/issues/3235) as well as in this [blog post](https://blog.mehdi.cc/articles/vitepress-cleanurls-on-nginx-environment#readings) by Mehdi Merah.

Loading…
Cancel
Save