web-dev-qa-db-ja.com

REST API用のApacheのHTTPSプロキシ

基本的な質問のように聞こえますが、Apache構成についてはわかりません。どんな助けでも素晴らしいでしょう。

Open TSDB はhttpsをサポートせず(REST API)を介して)、Apacheまたは「Apache Tomcat」でhttpsプロキシを作成します。たとえば、ローカルマシンにはTSDBとApahceの両方があります。Apacheはhttpとhttpsを受け入れる必要があります。https://<PUBLIC IP>/api/inputに送信すると、同じマシンのTSDBに転送されます(またはTSDBが別のマシンにいる)http

大きな絵

MY Code <----> https://<PUBLIC IP>/api/input <---- Proxy to ----> http://localhost/api/input

上記でApache Tomcatについて述べましたが、これは主にApache Tomcatを他の目的で使用しているため、最優先事項はTomcatです(Tomcatで可能ですか?)。

注:ApacheApache Tomcatの違いを知っています:Apacheはhttp Webサーバーであり、httpトラフィックのみを処理します。Tomcatリクエストを処理するサーブレットコンテナです(Javaの場合のみ)。ビルドでは、TomcatにApacheが含まれています(間違っている場合は修正してください)。

2

Apache HTTPDでは、基本的には次のようになります。

<VirtualHost *:80>
ServerName publicname.example.com
Redirect / https://publicname.example.com/
</VirtualHost>

<VirtualHost *:443>
ServerName publicname.example.com
SSLEngine on
SSLCertificateFile /path/to/cert.pem
SSLCertificateKeyFile /path/to/key.pem
ErrorLog /path/to/logs/publicaname.example.com-ssl-error.log
CustomLog /path/to/logs/publicaname.example.com-ssl.log combined

ProxyPass /api/input http://127.0.0.1:8080/api/input
ProxyPassReverse /api/input http://127.0.0.1:8080/api/input
</VirtualHost>

注:mod_proxyおよびmod_proxy_httpモジュールを最初にロードする必要があります。

2
ezra-s

@ ezra-sのおかげで、データを送信できます。しかし、その間私は少し苦労したので、いくつかの情報を共有したいだけです。

1 .Sudo apt-get install -y libapache2-mod-proxy-html libxml2-dev Apache2-prefork-dev libxml2-dev

2.モジュールの有効化

Sudo a2enmod proxy proxy_ajp proxy_http rewrite deflate headers proxy_balancer proxy_connect proxy_htm ssl

3.生成された自己署名証明書 ここにガイドがあります

4. /etc/Apache2/sites-enabled/000-default.confに設定を追加しました

5. Sudo service Apache2 restartを再起動しようとしました。しかし、エラーが発生しました

 * Starting web server Apache2                                                                                                                  * 
 * The Apache2 configtest failed.
Output of config test was:
[Mon Feb 13 02:31:06.772053 2017] [proxy_html:notice] [pid 8060] AH01425: I18n support in mod_proxy_html requires mod_xml2enc. Without it, non-ASCII characters in proxied pages are likely to display incorrectly.
AH00526: Syntax error on line 39 of /etc/Apache2/sites-enabled/000-default.conf:
ProxyPass Unable to parse URL
Action 'configtest' failed.
The Apache error log may have more information.

長いインターネット検索の後、私は mod_xml2encが利用できないバグ を見つけました。だから、私はソースからこのモジュールを構築しました

Sudo apt-get install Apache2-prefork-dev libxml2 libxml2-dev
mkdir ~/modbuild/ && cd ~/modbuild/
wget http://Apache.webthing.com/svn/Apache/filters/mod_xml2enc.c
wget http://Apache.webthing.com/svn/Apache/filters/mod_xml2enc.h
Sudo apxs2 -aic -I/usr/include/libxml2 ./mod_xml2enc.c
cd ~
rm -rfd ~/modbuild/
Sudo service Apache2 restart
 * Restarting web server Apache2                                                                                                               AH00558: Apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1. Set the 'ServerName' directive globally to suppress this message
                                                                                                                                        [ OK ]

助けてくれてありがとう!

1