DTV AdventCalender 19日目の記事です
2016/04/09ページ末尾に追記
私事なのだけども,ChinachuにNginxをかまして運用している.
httpsで公開している.
locationのところでChinachuを公開するようにして,別のホストのサーバーに
プロキシしている.
proxy_set_headerでUpgradeとConnectionを設定してるのはWebSocketのため.
それとこれだと認証がないので,実際の運用ではNginxで認証かけてます.
最初はNginxのdigest認証モジュールを使おうとおもったのだけど,
http://tokcs.com/archives/1810
にあるように規格違反なバグが存在している.
他にもalgorithm=MD5とすべきを"MD5"としていたり,RFCに記述されてるEBNFをちゃんと読み取れてない事に起因するバグを複数みつけてしまい,VLCのdigest認証が予想以上に厳格だったのでつらくなった.
AURにdigestモジュールのNginxがなかったこともあって,
先のURLにあったパッチと手元で作ったパッチを適用するAURパッケージを作っておいた
https://aur.archlinux.org/packages/nginx-http-auth-digest/
が,Chromeなどでは使えるが未だにVLCに認証エラーで弾かれるのでまだバグがあるのだと思う.だれかNginxでdigest認証プラグインを運用してる人,教えてください.
次にChinachuの改変.
Chinachuはべつに特に設定する事なくちゃんと動いてくれるのだが,
Chinachuから動画を見ようとするとChinachuのAPIが返すjsonのパスがChinachuがルートで動いてる前提になっていて見れなかったりする.
次のパッチで解決.
以上で,Chinachuをドメインのサブディレクトリ以下で公開する事ができた.
まああんまりこういうことしてる人っていないと思うので,誰の役に立つかはわからないが,メモでした.
追記:
2015年11月のコミットで既に対応していたのに気がつきませんでした……
commit 5de01b3dfbe79ed33109b24bf91e2d8c985d69c4
author: takaakis62 <takaakis62@users.noreply.github.com>
WUI/Client: リバースプロキシ使用時に再生できない問題を修正
とのことでした.
アップデートは頻繁にやりましょう……
2016/04/09ページ末尾に追記
私事なのだけども,ChinachuにNginxをかまして運用している.
また,いろいろあってドメインのルートではなくディレクトリの下で動かしたかった.
そのためにやったいくつかのメモです.
まず,Nginxの設定.一部抜粋.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
server { | |
listen 80; | |
listen [::]:80; | |
server_name chinachu.domain; | |
return 301 https://$host$request_uri; | |
} | |
server { | |
listen 443 ssl default_server; | |
listen [::]:443 ssl default_server; | |
server_name chinachu.domain; | |
add_header Strict-Transport-Security 'max-age=31535999; includeSubDomains;'; | |
ssl_certificate /etc/nginx/ssl/cert.pem; | |
ssl_certificate_key /etc/nginx/ssl/server.key; | |
ssl on; | |
ssl_prefer_server_ciphers on; | |
ssl_protocols TLSv1.1 TLSv1.2 SSLv3; | |
ssl_ciphers EECDH+AESGCM:EECDH+AES:EDH+AES:!DSS; | |
ssl_dhparam /etc/nginx/ssl/dhparam.pem; | |
ssl_stapling on; | |
ssl_stapling_verify on; | |
ssl_trusted_certificate /etc/nginx/ssl/trustedcert.pem; | |
resolver 192.168.1.1; | |
ssl_session_tickets on; | |
ssl_session_ticket_key /etc/nginx/ssl/sslsessionticket.key; | |
ssl_session_cache shared:SSL:10m; | |
ssl_session_timeout 10m; | |
location ^~ /chinachu/ { | |
proxy_pass http://192.168.1.172:10772/; | |
proxy_redirect http:// https://; | |
proxy_http_version 1.1; | |
proxy_set_header Host $host; | |
proxy_set_header Upgrade $http_upgrade; | |
proxy_set_header Connection "upgrade"; | |
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 https; | |
proxy_set_header Host $host; | |
proxy_buffering off; | |
} | |
} |
locationのところでChinachuを公開するようにして,別のホストのサーバーに
プロキシしている.
proxy_set_headerでUpgradeとConnectionを設定してるのはWebSocketのため.
それとこれだと認証がないので,実際の運用ではNginxで認証かけてます.
最初はNginxのdigest認証モジュールを使おうとおもったのだけど,
http://tokcs.com/archives/1810
にあるように規格違反なバグが存在している.
他にもalgorithm=MD5とすべきを"MD5"としていたり,RFCに記述されてるEBNFをちゃんと読み取れてない事に起因するバグを複数みつけてしまい,VLCのdigest認証が予想以上に厳格だったのでつらくなった.
AURにdigestモジュールのNginxがなかったこともあって,
先のURLにあったパッチと手元で作ったパッチを適用するAURパッケージを作っておいた
https://aur.archlinux.org/packages/nginx-http-auth-digest/
が,Chromeなどでは使えるが未だにVLCに認証エラーで弾かれるのでまだバグがあるのだと思う.だれかNginxでdigest認証プラグインを運用してる人,教えてください.
次にChinachuの改変.
Chinachuはべつに特に設定する事なくちゃんと動いてくれるのだが,
Chinachuから動画を見ようとするとChinachuのAPIが返すjsonのパスがChinachuがルートで動いてる前提になっていて見れなかったりする.
次のパッチで解決.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/web/page/channel/watch.js b/web/page/channel/watch.js | |
index 1302eb1..5a50ddc 100644 | |
--- a/web/page/channel/watch.js | |
+++ b/web/page/channel/watch.js | |
@@ -102,7 +102,7 @@ P = Class.create(P, { | |
var d = this.form.result(); | |
- d.prefix = window.location.protocol + '//' + window.location.host + '/api/channel/' + this.channelId + '/'; | |
+ d.prefix = window.location.protocol + '//' + window.location.host + '/chinachu/api/channel/' + this.channelId + '/'; | |
window.open('./api/channel/' + this.channelId + '/watch.xspf?' + Object.toQueryString(d)); | |
}.bind(this) | |
} | |
@@ -433,7 +433,7 @@ P = Class.create(P, { | |
var getRequestURI = function() { | |
var r = window.location.protocol + '//' + window.location.host; | |
- r += '/api/channel/' + this.channelId + '/watch.' + d.ext; | |
+ r += '/chinachu/api/channel/' + this.channelId + '/watch.' + d.ext; | |
var q = Object.toQueryString(d); | |
return r + '?' + q; | |
diff --git a/web/page/program/watch.js b/web/page/program/watch.js | |
index 87c7fc2..7056b84 100644 | |
--- a/web/page/program/watch.js | |
+++ b/web/page/program/watch.js | |
@@ -148,10 +148,10 @@ P = Class.create(P, { | |
saveSettings(d); | |
if (program._isRecording) { | |
- d.prefix = window.location.protocol + '//' + window.location.host + '/api/recording/' + program.id + '/'; | |
+ d.prefix = window.location.protocol + '//' + window.location.host + '/chinachu/api/recording/' + program.id + '/'; | |
window.open('./api/recording/' + program.id + '/watch.xspf?' + Object.toQueryString(d)); | |
} else { | |
- d.prefix = window.location.protocol + '//' + window.location.host + '/api/recorded/' + program.id + '/'; | |
+ d.prefix = window.location.protocol + '//' + window.location.host + '/chinachu/api/recorded/' + program.id + '/'; | |
window.open('./api/recorded/' + program.id + '/watch.xspf?' + Object.toQueryString(d)); | |
} | |
}.bind(this) | |
@@ -494,7 +494,7 @@ P = Class.create(P, { | |
var getRequestURI = function() { | |
var r = window.location.protocol + '//' + window.location.host; | |
- r += '/api/' + (!!p._isRecording ? 'recording' : 'recorded') + '/' + p.id + '/watch.' + d.ext; | |
+ r += '/chinachu/api/' + (!!p._isRecording ? 'recording' : 'recorded') + '/' + p.id + '/watch.' + d.ext; | |
var q = Object.toQueryString(d); | |
return r + '?' + q; |
まああんまりこういうことしてる人っていないと思うので,誰の役に立つかはわからないが,メモでした.
追記:
2015年11月のコミットで既に対応していたのに気がつきませんでした……
commit 5de01b3dfbe79ed33109b24bf91e2d8c985d69c4
author: takaakis62 <takaakis62@users.noreply.github.com>
WUI/Client: リバースプロキシ使用時に再生できない問題を修正
とのことでした.
アップデートは頻繁にやりましょう……