# HAProxy Proxying
As Strapi does not handle SSL directly and hosting a Node.js service on the "edge" network is not a secure solution it is recommended that you use some sort of proxy application such as Nginx, Apache, HAProxy, Traefik, or others. Below you will find some sample configurations for HAProxy, naturally these configs may not suit all environments and you will likely need to adjust them to fit your needs.
The below examples are acting as an "SSL termination" proxy, meaning that HAProxy is only accepting the requests on SSL and proxying to other backend services such as Strapi or other web servers. HAProxy cannot serve static content and as such it is usually used to handle multi-server deployments in a failover or load-balance situation. The examples provided below are based around everything existing on the same server, but could easily be tweaked for multi-server deployments.
# Strapi 服务
这些示例使用默认的 API 前缀
/api. 这可以更改，而无需直接修改 Nginx 配置 (请参阅 API prefix 文档).
yarn build 或
npm run build 重新构建管理面板。
The following examples are either proxying all requests directly to Strapi or are splitting requests between Strapi and some other backend web server such as Nginx, Apache, or others.
Below are 3 example HAProxy configurations:
- Sub-domain based such as
- subfolder based with both the API and Admin on the same subfolder such as
- subfolder based with split API and Admin such as
✋ HAProxy SSL Support
If you are not familiar with HAProxy and using SSL certificates on the bind directive, you should combine your SSL cert, key, and any CA files into a single
.pem package and use it's path in the bind directive. For more information see HAProxy's bind documentation (opens new window). Most Let's Encrypt clients do not generate a file like this so you may need custom "after issue" scripts to do this for you.
<html> <head> <meta http-equiv="refresh" content="0;URL='/admin'" /> </head> </html>