Nginx server
  • 05 Jul 2022
  • 4 Minutes à lire
  • Contributeurs
  • Sombre
    Lumière
  • PDF

Nginx server

  • Sombre
    Lumière
  • PDF

There is no French content available for this article, You are viewing the fallback version (English).

Nginx is an open-source web server.
To know more, visit the Nginx documentation


To set up a subfolder/subdirectory

Example premise

Important: Replace the example domain with your own document360 provided domain/custom domain.

  • Example domain represented using example.document360.io and the subfolder/subdirectory path (/docs) as example.document360.io/docs
  1. Add the following location blocks in your Nginx configuration file (/etc/nginx/default).
location /docs {
    proxy_pass https://example.document360.io/docs;
    proxy_set_header Host example.document360.io;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto $scheme;
    proxy_set_header "requested-by" "proxy";
}
  1. Restart the Nginx web server

For example, If you are using Nginx on Linux, then use the command
$ sudo systemctl restart nginx


To setup on other than '/docs' path

You can also set up your knowledge base on subdirectory paths other than /docs.

For example, /help, /support, etc.

When setting up other paths, add the languages associated with each version.

A few more lines need to be added to achieve this. Restart the server once done.

Example premise

Important: Replace the Document360 provided domain and the subdirectory domain with your own domains.
Also, replace the version name, subfolder path, and language with your own requirement.

  • Document360 provided domain represented as example.document360.io
  • Version name represented as /v1/
  • Subfolder path represented as /help/
  • Language represented as /he for Hebrew.
location /help {
    proxy_pass https://example.document360.io/docs;
    proxy_set_header Host example.document360.io;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto $scheme;
    proxy_set_header "requested-by" "proxy";

    sub_filter "v1/docs/" "v1/help/";
    sub_filter "docs/he/" "/help/he";
    sub_filter "/docs/" "/help/";
    sub_filter_once off;
}
  1. Restart the Nginx web server

For example, If you are using Nginx on Linux, then use the command
$ sudo systemctl restart nginx


To enable version(s) dropdown

If you want to enable the version dropdown navigation for your project when you host in a custom subdirectory and path, add the following codes for each of the versions available in your project.

Example premise

Let's assume there are two versions available in your project V1 and V2. In that case, you need to add two different code blocks, one for each version.

Important: Replace the Document360 provided domain and the subdirectory domain with your own domains.
Also, replace the version name, subfolder path, and language with your own requirement.

  • Document360 provided domain represented as example.document360.io
  • Version paths represented as /v1/, /v2/
  • Subfolder path represented as /help/
  • Language represented as /he for Hebrew.
location /v2/help {
    proxy_pass https://example.document360.io/v2/docs;
    proxy_set_header Host example.document360.io;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto $scheme;
    proxy_set_header "requested-by" "proxy";

    sub_filter "v2/docs/" "v2/help/";
    sub_filter "docs/he/" "/help/he";
    sub_filter "/docs/" "/help/";
    sub_filter_once off;
}
-----------------------------------------------------
location /v1/help {
    proxy_pass https://example.document360.io/v1/docs;
    proxy_set_header Host example.document360.io;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto $scheme;
    proxy_set_header "requested-by" "proxy";

    sub_filter "v1/docs/" "v1/help/";
    sub_filter "docs/he/" "/help/he";
    sub_filter "/docs/" "/help/";
    sub_filter_once off;
}
-----------------------------------------------------
location = /v2/docs {
    return 301 /v2/help;
}
-----------------------------------------------------
location = /v1/docs {
    return 301 /v1/help;
}

If you want your readers to navigate between the different public version(s) of your project from the dropdown (on mouse click), add the location block for all available versions.

  1. Restart the Nginx web server

For example, If you are using Nginx on Linux, then use the command
$ sudo systemctl restart nginx


Here are few external links which may help you in understanding the Nginx server location blocks in detail:


Sitemap generation

Example premise

Important: Replace the example domain with your own document360 provided domain/custom domain.


  • Example domain represented using example.document360.io

  • The sitemap prefix remains the same except for the language code (en, fr, de,etc.) example.document360.io/sitemap.xml.en
location /sitemap.xml.en {
proxy_pass https://example.document360.io/sitemap.xml.en;
proxy_set_header Host example.document360.io;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header "requested-by" "proxy";


Home page hosted on a subfolder

To host your project's home page on a custom subdirectory/subfolder path, add the following codes for each of the home page versions available in your project.

Example premise

Let's assume there are two versions and respective home pages available in your project V1 and V2. In that case, you need to add two different code blocks, one for each version.

Important: Replace the Document360 provided domain and the subdirectory domain with your own domains.
Also, replace the version name, subfolder path, and language with your own requirement.

  • Document360 provided domain represented as example.document360.io
  • Version paths represented as /v1/, /v2/
location =/v1 {
proxy_pass https://example.document360.io/;
proxy_set_header Host example.document360.io;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header "requested-by" "proxy";
}
location =/v2 {
proxy_pass https://example.document360.io/;
proxy_set_header Host example.document360.io;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header "requested-by" "proxy";
}
location /v1/en {
  return 301 /v1;
}
location /v2/en {
  return 301 /v2;
}

Exact match

location =/help {

'=' The equal sign can be used if the location needs to match the exact request URI. When this modifier is matched, the search stops right here.
Read more →

  1. Restart the Nginx web server

For example, If you are using Nginx on Linux, then use the command
$ sudo systemctl restart nginx

Knowledge base site home page

For a knowledge base site, the default home page is delivered in the root directory link ( For example, example.document360.io).
If the project contains version and language specific home page, the slug following the root directory would be /<version_name>/<language_code>. (For example, example.document360.io/v2/he)

Why is my site home page not available?

Make sure you have designed and published the project's home page in the portal's home page builder.


What happens next?

Once you have successfully configured the web server, your knowledge base site is now live on your custom subfolder/subdirectory. However, the existing URL for your project will serve the requests.

For example, example.document360.io and example.com/docs (if /docs is your folder path) will point to the knowledge base site.

This may cause duplicate content in search engines (Google, Bing, etc.). To prevent this - a redirect from Document360 project sub-domain to your custom-domain will be required.

To enable the redirect from example.document360.io to example.com/docs, please contact us at support@document360.com.


Cet article vous a-t-il été utile ?