需要海关域名
这个 neeto-custom-domains-nano 管理自定义域跨越 neto
应用.
目录
带有主机应用程序的开发
引擎为netoCustomDomains提供后端设置.
安装
- 将此行添加到您的应用程序的 Gemfile 中 :
source "NEETO_GEM_SERVER_URL" do
# ... existing gems
gem "neeto-custom-domains-engine"
end
- 然后执行:
bundle install
- 运行迁移
rails neeto_custom_domains_engine:install:migrations
rails db:migrate
使用量
- 添加关联
# If custom domain is associated to Organization
class Organization < ApplicationRecord
include NeetoCustomDomainsEngine::CustomDomainable
end
# If custom domain is associated to other resources (eg: Site)
class Site < ApplicationRecord
include NeetoCustomDomainsEngine::CustomDomainable
end
关注的还有: custom_domains 协会, primary_custom_domain 财务报告和审定财务报表
canonical_root_url(fallback)删除任何 has_many :custom_domains 或者说
primary_custom_domain 模型已经定义了。 模型方法凌驾于
关切,而该关切的版本只返回一个没有
重定向,即光子URL和重定向依赖.
- 添加控制器
所有常见的控制器逻辑被提取到引擎上. 然而,我们仍然需要 从主机应用程序控制器上装入一些记录.
如果自定义域与 Organization,添加一个
Api::V1::CustomDomainable 在主机应用程序中关注并将其纳入
控制器。 控制器。 这使得装载器可以跨需要它的控制器重新使用.
# app/controllers/concerns/api/v1/custom_domainable.rb
module Api::V1::CustomDomainable
extend ActiveSupport::Concern
private
def load_custom_domainable!
@custom_domainable = organization
end
end
class Api::V1::Admin::CustomDomainsController < NeetoCustomDomainsEngine::DomainsController
include Api::V1::CustomDomainable
end
如果自定义域与另一个资源(如. Site),定义
load_custom_domainable! 直接在控制器中:
class Api::V1::Admin::CustomDomainsController < NeetoCustomDomainsEngine::DomainsController
private
def load_custom_domainable!
@custom_domainable = organization.sites.find(params[:site_id])
end
end
- 添加一个
CustomDomainConcern模式关注
发动机的 NeetoCustomDomainsEngine::Domain 模式需求 custom_domain_url
财务报告和审定财务报表 organization 可在域名记录中查阅——用于
例如,在通知电子邮件中生成链接时,以及在按下
域名.
在下面的精确路径下定义主机应用程序中的顾虑. 发动机
自动包含通过 include CustomDomainConcern if defined?(CustomDomainConcern), (中文(简体) ),
因此不需要初始器或手动补丁——铁路自动加载处理.
返回路径 custom_domain_url 是特定产品。 指着它
无论自定义域设置页面挂载在您的产品管理器中
面板(下面的示例使用NeetoQuiz的路径;替换为您的产品).
# app/models/concerns/custom_domain_concern.rb
module CustomDomainConcern
extend ActiveSupport::Concern
def custom_domain_url
root_url = organization.root_url
# Replace this path with the route to the custom domain settings page
# in your product's admin panel.
"#{root_url}/admin/admin-panel/custom-domain"
end
def organization
custom_domainable
end
end
如果 custom_domainable 这不是 Organization (例如:. Site, (中文(简体) ),
更新 organization 转至自己的组织(例如:.
custom_domainable.organization) (中文(简体) ).
- 在您的应用程序中包含以下模块
config/routes.rb文件 :
include NeetoCustomDomainsEngine::Routes::Draw
- 定义所需路线.
# config/routes.rb
custom_domains_routes :acme
# routes/api.rb within the admin routes
custom_domains_routes :domain
- 添加前端组件 .
url应该是自定义域的 api 控制器。 控制器.
import { CustomDomain as NeetoCustomDomainDashboard } from "@bigbinary/neeto-custom-domains-frontend";
import { BASE_API_V1_URL, SINGULAR } from "neetocommons/constants";
import HelpPopover from "neetomolecules/HelpPopover";
import { useTranslation } from "react-i18next";
import routes from "routes";
import { EVENTS } from "src/constants";
import { CUSTOM_DOMAIN_HELP_DOC_URL } from "src/constants/urls";
const CustomDomain = () => {
const { t } = useTranslation();
const breadcrumbs = [
{ link: routes.admin.settings.index, text: t("titles.settings") },
{
link: routes.admin.settings.customDomain,
text: t("neetoCustomDomains.customDomain", SINGULAR),
},
];
const CUSTOM_DOMAIN_DNS_PROVIDER_HELP_DOCS = {
cloudflare: {
subdomain: `${PERMANENT_URL}/permanent-url-1`,
rootDomain: `${PERMANENT_URL}/permanent-url-2`,
},
unknown: {
subdomain: `${PERMANENT_URL}/permanent-url-3`,
rootDomain: `${PERMANENT_URL}/permanent-url-4`,
},
namecheap: {
subdomain: `${PERMANENT_URL}/permanent-url-5`,
rootDomain: `${PERMANENT_URL}/permanent-url-6`,
},
hostinger: {
subdomain: `${PERMANENT_URL}/permanent-url-7`,
rootDomain: `${PERMANENT_URL}/permanent-url-8`,
},
digitalocean: {
subdomain: `${PERMANENT_URL}/permanent-url-9`,
rootDomain: `${PERMANENT_URL}/permanent-url-10`,
},
godaddy: {
subdomain: `${PERMANENT_URL}/permanent-url-11`,
rootDomain: `${PERMANENT_URL}/permanent-url-12`,
},
squarespace: {
subdomain: `${PERMANENT_URL}/permanent-url-13`,
rootDomain: `${PERMANENT_URL}/permanent-url-14`,
},
wix: {
subdomain: `${PERMANENT_URL}/permanent-url-15`,
rootDomain: `${PERMANENT_URL}/permanent-url-16`,
},
porkbun: {
subdomain: `${PERMANENT_URL}/permanent-url-17`,
rootDomain: `${PERMANENT_URL}/permanent-url-18`,
},
networksolutions: {
subdomain: `${PERMANENT_URL}/permanent-url-19`,
rootDomain: `${PERMANENT_URL}/permanent-url-20`,
},
aws: {
subdomain: `${PERMANENT_URL}/permanent-url-21`,
rootDomain: `${PERMANENT_URL}/permanent-url-22`,
},
strato: {
subdomain: `${PERMANENT_URL}/permanent-url-23`,
rootDomain: `${PERMANENT_URL}/permanent-url-24`,
},
}
return (
<div className="w-full">
<NeetoCustomDomainDashboard
appName="appname" // Eg: `cal`, `form`
dnsHelpDocs={CUSTOM_DOMAIN_DNS_PROVIDER_HELP_DOCS}
helpDocUrl={CUSTOM_DOMAIN_HELP_DOC_URL}
subdomainPlaceholder="subdomain-placeholder" // Eg: `schedule` for NeetoCal and `form` for NeetoForm
url={`${BASE_URL}/custom-domains`}
{ ...{ breadcrumbs } }
/>
</div>
);
};
export default CustomDomain;
- 挂载
CustomDomain在理想路径中实现组件.
SIO: 重定向到自定义域和犬类 URL
一旦自定义域激活,产品子域上的公开页面应当 重定向到它,而犬形URL应该指向它.
- 包含
NeetoCustomDomainsEngine::CanonicalHostRedirection在公众中 只有基础控制器。 永不包含在管理员、 API 或 认证控制器中 . 他们必须继续工作 在子域,所以客户的域破 还可以登录并修复. - 关注的内容是:
@organization。如果可域为 其它( 如: a)Site),推翻私有方法canonical_custom_domainable。 。 。 . - 使用
canonical_url页:1<link rel="canonical">财务报告和审定财务报表og:url它会保持?page=N的页面,并删除其他查询参数. - 构建站点映射和机器人 URL
canonical_root_url(fallback),其中 倒置是子域基址.
GET 和 HEAD 请求在子域上获得一个 301 到同一路径并查询
主自定义域。 重定向只在域时发生
活动且没有自己的方向。 否则子域服务于
页面和目录 URL 返回到子域。 这些要求从来没有
重定向: JSON 请求, 浏览器加载不属于顶级页面
导航(a) Sec-Fetch-Dest 其他 document,例如iframes,获取
和XHR呼叫或图像),签名用户(因此是私人内容和草稿)
预览会继续在子域上工作,并请求其它自定义
域名。 301型机车被私藏一个小时.
每个重定向臂都有一个存储证书域活性探测器. 若为
重新定向的请求不会在一分钟内到达自定义域,
引擎运行 ReconcileCertificateJob 对于这个领域。 无法实现的域
超过一个小时的地址被标记失败, 并且所有者会收到电子邮件 。 在自定义域上被击中,或者一个探测器, 被信任为六至
7小时,所以每个域 探测最多一次在该窗口.
ENV 变量
对于这个引擎的运行,我们需要以下的env变量.
LETS_ENCRYPT_PRIVATE_KEY: < For requesting SSL certificates >
LETS_ENCRYPT_DIRECTORY_URL: < For requesting SSL certificates >
LETS_ENCRYPT_APP_NAME: < For pushing SSL certificate and custom domains >
NEETO_DEPLOY_APP: < To identify in which platform the app is deployed NeetoDEploy/Heroku>
NEETO_DEPLOY_AUTH_TOKEN: <For pushing SSL certificate and custom domains>
可选的,仅进行:
CUSTOM_DOMAIN_EDGE_CERTIFICATE_SUFFIX: < e.g. review.neetoautomation.com >
主机名在此后缀下的一个标签在未进行DNS检查或检查的情况下被激活
证书, 因为 Cloudflare 的通配证书已经为他们服务 。 没错
仅在 Rails.env.staging?,所以设置它 任何地方没有效果.
将已有域迁移到 Cloudflare
Cloudflare- for-SaaS 启用之前创建的域没有路由
登记 - CloudflareValidationSyncJob 仅当一个域是
创建, 或当获取 DCV 令牌时 。 回填任务就是这条路线. 运行它
在每个产品内,一次一个产品.
# Changes nothing. Shows what would be registered.
bundle exec rake neeto_custom_domains_engine:cloudflare:backfill_report
# Registers them.
bundle exec rake neeto_custom_domains_engine:cloudflare:backfill
它拒绝运行,除非 NEETO_CUSTOM_DOMAINS_CERTIFICATE_BACKEND 实值 dual 或者说
cloudflare 以及两者 CLOUDFLARE_SAAS_ZONE_ID 财务报告和审定财务报表 CLOUDFLARE_SAAS_API_TOKEN
已经设定.
| 变量 | 默认 | 它会做什么 |
|---|---|---|
MAX_IN_FLIGHT | 100 | 有多少个证书可以同时验证 |
LIMIT | 无 | 一次放出这么多就停止 |
MAX_MINUTES | 120 | 运行停止前的时钟预算 |
MAX_IN_FLIGHT 这是最重要的一个. 登记费用 API 单次通话
每个域,但每个域 等待验证民意测验 云浮大约10
每5分钟一次。 每5分钟1,200个请求限值
让天花板在120个证书左右飞行 默认离开
头室. 提高它的风险是同时限制每个产品的速度,因为限制
是每个账户而不是每个区域.
任务可以安全停止和重运行:一个已经持有
cloudflare_hostname_id 被跳过。 仅 active 域已注册 -
(单位:千美元) failed 域名的 DNS 不指向我们, 所以注册它只是
对抗CA 域还原 pending 以后再跑一次再接回来
他们开始活动.
一次只能有一个回填;通过Redis锁拒绝第二个回填.
登记不是一种削减。 它离开,让我们加密服务 和云花 一边闲逛 仅当域名的 DNS 开始指向一个 代理主机名.
出版指令
咨询 构建和释放软件包 关于如何出版的详细指南.
一体化
- 尼托卡尔
- 内托格式
- 内托Kb
- 内托引擎
- 涅盘点
- Neeto 记录
- 尼托布吕克语Name
- Neeto 课程
- 新代码
- 涅托德斯克语Name
- 尼托基兹语Name
- 尼托规划器
- Neeto 发票
- 内托聊天
- 涅盘运行器