添加 RESTBase 配置文件

master
落雨楓 2 years ago
commit 746419feff

@ -0,0 +1,2 @@
# 异世界百科 配置文件
一些MediaWiki相关的配置文件用于参考

@ -0,0 +1,20 @@
# 异世界百科 RESTBase配置文件
已开启功能:
* mobileapps
* mathoid
* cxserver
* parsoid
站点:
* www.isekai.cn (zh.1meji.com)
* en.1meji.com
为了降低开销内部调用API使用HTTP进行访问需要在NginX配置对应path不进行HTTPS跳转或者将RESTBase中的API地址改为HTTPS
# MySQL缓存依赖
需要使用npm安装MySQL缓存扩展包
```sh
npm i restbase-mod-table-isekai-mysql --save
```

@ -0,0 +1,142 @@
services:
- name: restbase
module: hyperswitch
conf:
port: 7231
salt: secret
default_page_size: 125
user_agent: RESTBase
ui_name: RESTBase
ui_url: https://www.mediawiki.org/wiki/RESTBase
ui_title: RESTBase docs
spec:
x-request-filters:
- path: lib/security_response_header_filter.js
x-sub-request-filters:
- type: default
name: http
options:
allow:
- pattern: http://localhost/api.php
forward_headers: true
- pattern: http://localhost:7231
forward_headers: true
- pattern: http://localhost:8888
forward_headers: true
- pattern: http://www.isekai.cn
forward_headers: true
- pattern: http://en.1meji.com
forward_headers: true
- pattern: http://zh.1meji.com
forward_headers: true
- pattern: https://www.isekai.cn
forward_headers: true
- pattern: https://en.1meji.com
forward_headers: true
- pattern: https://zh.1meji.com
forward_headers: true
- pattern: http://localhost:10044
forward_headers: true
- pattern: /^https?:\/\//
paths:
/{domain:localhost}: &arbitary_domain_zh
x-modules:
- path: projects/isekai.yaml
options:
proxy:
backend_host_template: '{{"/{domain}/sys/legacy"}}'
block_external_reqs: true
action:
# XXX Check API URL!
apiUriTemplate: http://www.isekai.cn/api.php
# XXX Check the base RESTBase URI
baseUriTemplate: http://www.isekai.cn/api/rest_v1
parsoid:
# XXX Check Parsoid URL!
host: http://www.isekai.cn/rest.php
response_cache_control: 's-maxage=0, max-age=86400'
grace_ttl: 1000000
mathoid:
# XXX Check Mathoid URL!
host: http://localhost:10044
mobileapps:
host: http://localhost:8888
cxserver:
host: http://localhost:8297
table:
type: restbase-mysql
host: localhost
database: restbase
keyspace: system
username: root
password: root
pool_idle_timeout: 20000
retry_delay: 250
retry_limit: 10
show_sql: false
storage_groups:
- name: zh.1meji.com
domains: /./
purged_cache_control: test_purged_cache_control
# Cache control for purged endpoints allowing short-term client caching
purged_cache_control_client_cache: test_purged_cache_control_with_client_caching
/{domain:www.isekai.cn}: *arbitary_domain_zh
/{domain:zh.1meji.com}: *arbitary_domain_zh
/{domain:en.1meji.com}: &arbitary_domain_en
x-modules:
- path: projects/isekai.yaml
options:
proxy:
backend_host_template: '{{"/{domain}/sys/legacy"}}'
block_external_reqs: true
action:
# XXX Check API URL!
apiUriTemplate: http://en.1meji.com/api.php
# XXX Check the base RESTBase URI
baseUriTemplate: http://en.1meji.com/api/rest_v1
parsoid:
# XXX Check Parsoid URL!
host: http://en.1meji.com/rest.php
response_cache_control: 's-maxage=0, max-age=86400'
grace_ttl: 1000000
mathoid:
# XXX Check Mathoid URL!
host: http://localhost:10044
mobileapps:
host: http://localhost:8888
cxserver:
host: http://10.0.0.17:8297
table:
type: restbase-mysql
host: localhost
database: restbase
keyspace: system
username: root
password: root
pool_idle_timeout: 20000
retry_delay: 250
retry_limit: 10
show_sql: false
storage_groups:
- name: en.1meji.com
domains: /./
purged_cache_control: test_purged_cache_control
# Cache control for purged endpoints allowing short-term client caching
purged_cache_control_client_cache: test_purged_cache_control_with_client_caching
# Finally, a standard service-runner config.
info:
name: restbase
logging:
name: restbase
level: info
# Statsd metrics reporter
metrics:
type: statsd
host: localhost
port: 8125
num_workers: 1

@ -0,0 +1,135 @@
# will work with Mathoid on any {domain}
paths:
/{api:v1}:
x-modules:
# swagger options, overriding the shared ones from the merged specs (?)
- spec:
info:
version: 1.0.0
title: Wikimedia REST API
description: Welcome to your RESTBase API.
#securityDefinitions: &wp/content-security/1.0.0
# mediawiki_auth:
# description: Checks permissions using MW api
# type: apiKey
# in: header
# name: cookie
# x-internal-request-whitelist:
# - /http:\/\/[a-zA-Z0-9\.]+\/w\/api\.php/
# Override the base path for host-based (proxied) requests. In our case,
# we proxy https://{domain}/api/rest_v1/ to the API.
x-host-basePath: /api/rest_v1
x-route-filters:
- path: ./lib/normalize_title_filter.js
options:
redirect_cache_control: '{{options.purged_cache_control}}'
paths:
/media:
x-modules:
- path: v1/mathoid.yaml
options: '{{options.mathoid}}'
#/testing:
# x-modules:
# - path: ../mathpipe.yaml
# options: '{{options.mathoid}}'
/page:
x-modules:
- path: v1/content.yaml
options:
purged_cache_control: '{{options.purged_cache_control}}'
- path: v1/common_schemas.yaml # Doesn't really matter where to mount it.
- path: v1/mobileapps.js
# NOTE: We're setting the `no-store` cache-control header so that we don't
# store MCS results - we don't have pre-generation for wikivoyage.
options: '{{merge({"response_cache_control": options.purged_cache_control},
options.mobileapps)}}'
- path: v1/pcs/stored_endpoint.js
options:
name: media-list
response_cache_control: '{{options.purged_cache_control}}'
host: '{{options.mobileapps.host}}'
- path: v1/pcs/stored_endpoint.js
options:
name: mobile-html
response_cache_control: '{{options.purged_cache_control}}'
host: '{{options.mobileapps.host}}'
- path: v1/pcs/mobile-html-offline-resources.yaml
options:
host: '{{options.mobileapps.host}}'
- path: v1/talk.yaml
options:
host: '{{options.mobileapps.host}}'
/transform:
x-modules:
- path: v1/transform.yaml
- path: v1/pcs/transform.js
options:
mobileapps_host: '{{options.mobileapps.host}}'
cx_host: '{{options.cxserver.host}}'
/data:
x-modules:
- path: v1/citoid.js
options: '{{options.citoid}}'
- path: v1/lists.js
options: '{{options.lists}}'
- path: v1/css.yaml
options:
host: '{{options.mobileapps.host}}'
- path: v1/javascript.yaml
options:
host: '{{options.mobileapps.host}}'
- path: v1/i18n.yaml
options:
host: '{{options.mobileapps.host}}'
/key_value:
x-modules:
- path: sys/backend_proxy.js
options: '{{options.proxy}}'
/page_revisions:
x-modules:
- path: sys/backend_proxy.js
options: '{{options.proxy}}'
options: '{{options}}'
/{api:sys}:
x-modules:
- spec:
paths:
/mathoid:
x-modules:
- path: sys/mathoid.js
options: '{{options.mathoid}}'
/table:
x-modules:
- name: restbase-mod-table-isekai-mysql
version: 1.0.0
type: npm
options:
conf: '{{options.table}}'
/key_value:
x-modules:
- path: sys/key_value.js
/post_data: &sys_post_data
x-modules:
- path: sys/post_data.js
/events:
x-modules:
- path: sys/events.js
options: '{{options.events}}'
/page_revisions:
x-modules:
- path: sys/page_revisions.js
/action:
x-modules:
- path: sys/action.js
options: '{{options.action}}'
/page_save:
x-modules:
- path: sys/page_save.js
/parsoid:
x-modules:
- path: sys/parsoid.js
options:
parsoidHost: '{{options.parsoid.host}}'
response_cache_control: '{{options.purged_cache_control}}'
options: '{{options}}'
Loading…
Cancel
Save