1
0
Fork 0

发布应用 Iframely 应用

Signed-off-by: 萌森 <qyg2297248353@163.com>
This commit is contained in:
萌森 2024-08-07 16:07:17 +08:00
parent 9632e0d0ce
commit 8543fcfc12
4 changed files with 140 additions and 165 deletions

View File

@ -4,55 +4,30 @@ import {dirname} from 'path';
const __filename = fileURLToPath(import.meta.url); const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename); const __dirname = dirname(__filename);
// Optional SSL cert, if you serve under HTTPS. const proxyUrlBase = process.env.PROXY_URL || '';
/* const proxyUrl = proxyUrlBase ? `${proxyUrlBase}?url={url}` : '';
const ssl_key = const file = await readFile(new URL('./key.pem', import.meta.url), {encoding: 'utf8'});
const ssl_cert = await readFile(new URL('./cert.pem', import.meta.url), {encoding: 'utf8'});
*/
export default { export default {
// Specify a path for custom plugins. Custom plugins will override core plugins.
// CUSTOM_PLUGINS_PATH: __dirname + '/yourcustom-plugin-folder',
DEBUG: false, DEBUG: false,
RICH_LOG_ENABLED: false, RICH_LOG_ENABLED: false,
baseAppUrl: process.env.BASE_APP_URL || "http://localhost:8061",
// For embeds that require render, baseAppUrl will be used as the host.
baseAppUrl: "http://localhost:8061", // use "https://yourdomain.com/path" where you have Iframely in your reverse proxy
relativeStaticUrl: "/r", relativeStaticUrl: "/r",
// Or just skip built-in renders altogether
SKIP_IFRAMELY_RENDERS: true, SKIP_IFRAMELY_RENDERS: true,
// For legacy reasons the response format of Iframely open-source is
// different by default as it does not group the links array by rel.
// In order to get the same grouped response as in Cloud API,
// add `&group=true` to your request to change response per request
// or set `GROUP_LINKS` in your config to `true` for a global change.
GROUP_LINKS: true, GROUP_LINKS: true,
MAX_REDIRECTS: parseInt(process.env.MAX_REDIRECTS, 10) || 4,
// Number of maximum redirects to follow before aborting the page
// request with `redirect loop` error.
MAX_REDIRECTS: 4,
SKIP_OEMBED_RE_LIST: [ SKIP_OEMBED_RE_LIST: [
// /^https?:\/\/yourdomain\.com\//, // /^https?:\/\/yourdomain\.com\//,
], ],
/* /*
// Used to pass parameters to the generate functions when creating HTML elements
// disableSizeWrapper: Don't wrap element (iframe, video, etc) in a positioned div
GENERATE_LINK_PARAMS: { GENERATE_LINK_PARAMS: {
disableSizeWrapper: true disableSizeWrapper: true
}, },
*/ */
port: 8061, //can be overridden by PORT env var port: 8061,
host: '0.0.0.0', // Dockers beware. See https://github.com/itteco/iframely/issues/132#issuecomment-242991246 host: '0.0.0.0',
//can be overridden by HOST env var
// Optional SSL cert, if you serve under HTTPS.
/* /*
ssl: { ssl: {
key: ssl_key, key: ssl_key,
@ -61,100 +36,36 @@ export default {
}, },
*/ */
/*
Supported cache engines:
- no-cache - no caching will be used.
- node-cache - good for debug, node memory will be used (https://github.com/tcs-de/nodecache).
- redis - https://github.com/mranney/node_redis.
- memcached - https://github.com/3rd-Eden/node-memcached
*/
CACHE_ENGINE: 'node-cache', CACHE_ENGINE: 'node-cache',
CACHE_TTL: 0, // In seconds. CACHE_TTL: 0,
// 0 = 'never expire' for memcached & node-cache to let cache engine decide itself when to evict the record
// 0 = 'no cache' for redis. Use high enough (e.g. 365*24*60*60*1000) ttl for similar 'never expire' approach instead
/* /*
// Redis mode (cluster or standard)
REDIS_MODE: 'standard',
*/
/*
// Redis cache options.
REDIS_OPTIONS: {
socket: {
host: '127.0.0.1',
port: 6379
}
},
*/
/*
// Redis cluster options.
REDIS_CLUSTER_OPTIONS: {
servers: [
{
host: '10.0.0.10',
port: 6379
},
// ...
],
},
*/
/*
// Memcached options. See https://github.com/3rd-Eden/node-memcached#server-locations
MEMCACHED_OPTIONS: {
locations: "127.0.0.1:11211"
}
*/
/*
// Access-Control-Allow-Origin list.
allowedOrigins: [ allowedOrigins: [
"*", "*",
"http://another_domain.com" "http://another_domain.com"
], ],
*/ */
/* RESPONSE_TIMEOUT: 5 * 1000,
// Uncomment to enable plugin testing framework.
tests: {
mongodb: 'mongodb://localhost:27017/iframely-tests',
single_test_timeout: 10 * 1000,
plugin_test_period: 2 * 60 * 60 * 1000,
relaunch_script_period: 5 * 60 * 1000
},
*/
// If there's no response from remote server, the timeout will occur after
RESPONSE_TIMEOUT: 5 * 1000, //ms
// Customize API calls to oembed endpoints.
// Must have: please add your `access_token` for Facebook and Instagram API calls
ADD_OEMBED_PARAMS: [{ ADD_OEMBED_PARAMS: [{
re: [
re: [ // Endpoint's URL regexp array.
/^https:\/\/graph\.facebook\.com\/v[0-9\.]+\/instagram_oembed/i /^https:\/\/graph\.facebook\.com\/v[0-9\.]+\/instagram_oembed/i
], ],
params: { // Custom query-string params object. params: {
// TODO: get your access Insagtam token as described // TODO: get your access Insagtam token as described
// use `{app-id}|{app secret}` as access token
// on https://developers.facebook.com/docs/instagram/oembed/ // on https://developers.facebook.com/docs/instagram/oembed/
access_token: '', // The simplest way is access_token: '',
// to use `{app-id}|{app secret}` as access token
// Add any other optional params
hidecaption: true hidecaption: true
} }
}, { }, {
re: [/^https:\/\/graph\.facebook\.com\/v[0-9\.]+\/oembed_page/i], re: [/^https:\/\/graph\.facebook\.com\/v[0-9\.]+\/oembed_page/i],
params: { params: {
// TODO: get your access token as described // TODO: get your access token as described
// use `{app-id}|{app secret}` as access token
// on https://developers.facebook.com/docs/plugins/oembed // on https://developers.facebook.com/docs/plugins/oembed
access_token: '', // The simplest way is access_token: '',
// to use `{app-id}|{app secret}` as access token
// Add any other optional params
show_posts: 0, show_posts: 0,
show_facepile: 0, show_facepile: 0,
maxwidth: 600 maxwidth: 600
@ -172,46 +83,48 @@ export default {
re: [/^https:\/\/graph\.facebook\.com\/v[0-9\.]+\/oembed_/i], re: [/^https:\/\/graph\.facebook\.com\/v[0-9\.]+\/oembed_/i],
params: { params: {
// TODO: get your access token as described // TODO: get your access token as described
// use `{app-id}|{app secret}` as access token
// on https://developers.facebook.com/docs/plugins/oembed // on https://developers.facebook.com/docs/plugins/oembed
access_token: '', // The simplest way is access_token: '',
// to use `{app-id}|{app secret}` as access token
// Add any other optional params, like skip script tag and fb-root div // Add any other optional params, like skip script tag and fb-root div
// omitscript: true // omitscript: true
} }
}], }],
/* Configure use of HTTP proxies, headers as needed.
You don't have to specify all options per regex - just what you need to override ENABLED_PROXY: process.env.ENABLED_PROXY === 'true',
*/ PROXY_URL: proxyUrl,
/*
PROXY: [{ PROXY: [{
re: [/^https?:\/\/www\.domain\.com/], re: [
/^https?:\/\/www\.google\.com/,
// Either `proxy`, or `proxy_url`, or none. /^https?:\/\/www\.facebook\.com/,
proxy: true, // Will fetch URL via echo service configured as PROXY_URL. See below. /^https?:\/\/www\.twitter\.com/,
// proxy_url: 'http://1.2.3.4:8080?url={url}', // Will fetch URL via this exact echo service, see below. /^https?:\/\/www\.youtube\.com/,
/^https?:\/\/www\.instagram\.com/,
user_agent: 'CHANGE YOUR AGENT', /^https?:\/\/www\.whatsapp\.com/,
headers: { /^https?:\/\/www\.snapchat\.com/,
// HTTP headers /^https?:\/\/www\.tumblr\.com/,
// Overrides previous params if overlapped. /^https?:\/\/www\.reddit\.com/,
}, /^https?:\/\/www\.pinterest\.com/,
cache_ttl: 3600 // in seconds, cache response for 1 hour. /^https?:\/\/www\.flickr\.com/,
/^https?:\/\/www\.blogspot\.com/,
/^https?:\/\/www\.wordpress\.com/,
/^https?:\/\/www\.wikipedia\.org/,
/^https?:\/\/www\.imdb\.com/,
/^https?:\/\/www\.vimeo\.com/,
/^https?:\/\/www\.soundcloud\.com/,
/^https?:\/\/www\.spotify\.com/,
/^https?:\/\/www\.linkedin\.com/
],
proxy: process.env.ENABLED_PROXY === 'true',
proxy_url: proxyUrl,
user_agent: 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.3',
headers: {},
cache_ttl: 3600
}], }],
// Proxy now requires an echo service endpoint.
// See #354 and example code at
// https://gist.github.com/nleush/7916ee89f7b8d6f0cd478d7335702139
PROXY_URL: 'http://1.2.3.4:8080?url={url}', // Iframely will add `?url=...` to this endpoint
*/
// Customize API calls to 3rd parties. At the very least - configure required keys.
// For available provider options - please see the code of its domain plugin.
providerOptions: { providerOptions: {
locale: "en_US", // ISO 639-1 two-letter language code, e.g. en_CA or fr_CH. locale: "en_US",
// Will be added as highest priotity in accept-language header with each request.
// Plus is used in FB, YouTube and perhaps other plugins
"twitter": { "twitter": {
"max-width": 550, "max-width": 550,
"min-width": 250, "min-width": 250,
@ -220,19 +133,21 @@ export default {
omit_script: false, omit_script: false,
center: false, center: false,
// dnt: true, // dnt: true,
cache_ttl: 100 * 365 * 24 * 3600 // 100 Years. cache_ttl: 100 * 365 * 24 * 3600
}, },
readability: { readability: {
enabled: false enabled: false
// allowPTagDescription: true // to enable description fallback to first paragraph // to enable description fallback to first paragraph
// allowPTagDescription: true
}, },
images: { images: {
loadSize: false, // if true, will try an load first bytes of all images to get/confirm the sizes loadSize: false,
checkFavicon: false // if true, will verify all favicons checkFavicon: false
}, },
tumblr: { tumblr: {
consumer_key: "INSERT YOUR VALUE" consumer_key: "INSERT YOUR VALUE"
// media_only: true // disables status embeds for images and videos - will return plain media // disables status embeds for images and videos - will return plain media
// media_only: true
}, },
google: { google: {
// https://developers.google.com/maps/documentation/embed/guide#api_key // https://developers.google.com/maps/documentation/embed/guide#api_key
@ -248,24 +163,20 @@ export default {
}, },
*/ */
// List of query parameters to add to YouTube and Vimeo frames
// Start it with leading "?". Or omit alltogether for default values
// API key is optional, youtube will work without it too.
// It is probably the same API key you use for Google Maps.
youtube: { youtube: {
// api_key: "INSERT YOUR VALUE", // api_key: "INSERT YOUR VALUE",
// parts: [ "snippet", "player" ], // list of fields you want to use in the request, in most cases you only need those two // parts: [ "snippet", "player" ],
get_params: "?rel=0&showinfo=1", // https://developers.google.com/youtube/player_parameters, get_params: "?rel=0&showinfo=1",
fix_shorts_in_eu: true // Avoid consent redirect for EU servers fix_shorts_in_eu: true
}, },
vimeo: { vimeo: {
get_params: "?byline=0&badge=0" // https://developer.vimeo.com/player/embedding get_params: "?byline=0&badge=0"
}, },
soundcloud: { soundcloud: {
old_player: true // enables classic player old_player: true
}, },
giphy: { giphy: {
media_only: true // disables branded player for gifs and returns just the image media_only: true
}, },
bandcamp: { bandcamp: {
get_params: '/size=large/bgcol=333333/linkcol=ffffff/artwork=small/transparent=true/', get_params: '/size=large/bgcol=333333/linkcol=ffffff/artwork=small/transparent=true/',
@ -288,10 +199,6 @@ export default {
*/ */
}, },
// WHITELIST_WILDCARD, if present, will be added to whitelist as record for top level domain: "*"
// with it, you can define what parsers do when they run accross unknown publisher.
// If absent or empty, all generic media parsers will be disabled except for known domains
// More about format: https://iframely.com/docs/qa-format
/* /*
WHITELIST_WILDCARD: { WHITELIST_WILDCARD: {
@ -321,12 +228,10 @@ export default {
} }
*/ */
// The list of regexs to be ignored. Iframely will return 417
// At minimum, keep your localhosts ignored to avoid SSRF
IGNORE_DOMAINS_RE: [ IGNORE_DOMAINS_RE: [
/^https?:\/\/127\.0\.0\.1/i, /^https?:\/\/127\.0\.0\.1/i,
/^https?:\/\/localhost/i, /^https?:\/\/localhost/i,
/^https?:\/\/[^\/]+:\d+\/?/, // Blocks port-scan via DNS pointing to 127.0.0.1 /^https?:\/\/[^\/]+:\d+\/?/,
// And this is AWS metadata service // And this is AWS metadata service
// https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-instance-metadata.html // https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-instance-metadata.html

View File

@ -8,10 +8,36 @@ additionalProperties:
required: true required: true
rule: paramPort rule: paramPort
type: number type: number
- default: "" - default: "http://localhost:8061"
edit: true edit: true
envKey: HTTP_PROXY envKey: BASE_APP_URL
labelZh: 网络代理 labelZh: 域名地址
labelEn: Network Proxy labelEn: Domain URL
required: false required: false
type: text type: text
- default: "false"
edit: true
envKey: ENABLED_PROXY
labelZh: 是否开启代理
labelEn: Enable Proxy
required: true
type: select
values:
- label: 开启
value: "true"
- label: 关闭
value: "false"
- default: ""
edit: true
envKey: PROXY_URL
labelZh: 代理地址
labelEn: Proxy URL
required: false
type: text
- default: 4
edit: true
envKey: MAX_REDIRECTS
labelZh: 最大重定向次数
labelEn: Max Redirects
required: false
type: number

View File

@ -14,7 +14,7 @@ services:
networks: networks:
- 1panel-network - 1panel-network
ports: ports:
- ${PANEL_APP_PORT_HTTP}:8080 - ${PANEL_APP_PORT_HTTP}:8061
env_file: env_file:
- /etc/1panel/envs/global.env - /etc/1panel/envs/global.env
- ${ENV_FILE:-/etc/1panel/envs/default.env} - ${ENV_FILE:-/etc/1panel/envs/default.env}
@ -22,4 +22,6 @@ services:
- ./config/config.local.js:/iframely/config.local.js - ./config/config.local.js:/iframely/config.local.js
environment: environment:
- NODE_ENV=production - NODE_ENV=production
- PORT=8061
- HOST='0.0.0.0'
- HTTPS_PROXY=${HTTP_PROXY} - HTTPS_PROXY=${HTTP_PROXY}

View File

@ -10,19 +10,49 @@ iframely 是针对所有各种富媒体嵌入和 URL 数据的统一交付服务
## 特点 ## 特点
+ 最佳富媒体 🚀 最佳富媒体
iframely 了解来自 1900 多家出版商的富媒体并且还在不断增加。视频、音频、应用程序、照片和图像、幻灯片、播放列表、播客、地图、3D、表格、文档、谜题、测验、图表和信息图表。您会自动获得所有新的发布商。 iframely 了解来自 1900 多家出版商的富媒体并且还在不断增加。视频、音频、应用程序、照片和图像、幻灯片、播放列表、播客、地图、3D、表格、文档、谜题、测验、图表和信息图表。您会自动获得所有新的发布商。
## API 端点 ## 安装说明
+ 请求示例 由于 `api_key` 属于 Iframely云托管服务使用自托管服务将无法配置 `api_key`,保障接口的安全性。
> API 端点: '/oembed' and '/iframely'
>
> Debugger UI: '/debug'
### 代理配置
基本格式:`{protocol}://{host}:{port}`
+ `protocol` - 代理服务器的协议
+ `host` - 代理服务器的主机名
+ `port` - 代理服务器的端口号
### 其他配置
自行修改 `config/config.local.js` 配置文件,重启生效
## API 说明
### 请求示例
端点:`/oembed`
```http request ```http request
${domain}/api/oembed?url={URL}&api_key={API_KEY} ${domain}/oembed?url={URL}
``` ```
+ 响应示例 端点:`/iframely`
```http request
${domain}/iframely?url={URL}
```
### 响应示例
> 官方
```json ```json
{ {
@ -41,6 +71,18 @@ ${domain}/api/oembed?url={URL}&api_key={API_KEY}
} }
``` ```
> 百度一下
```json
{
"type": "link",
"version": "1.0",
"title": "百度一下,你就知道",
"url": "http://www.baidu.com/",
"description": "全球领先的中文搜索引擎、致力于让网民更便捷地获取信息,找到所求。百度超过千亿的中文网页数据库,可以瞬间找到相关的搜索结果。"
}
```
--- ---
![Ms Studio](https://file.lifebus.top/imgs/ms_blank_001.png) ![Ms Studio](https://file.lifebus.top/imgs/ms_blank_001.png)