將入口網站設為使用 HTTPS

Developer Services Portal 4.17.05 版

Apigee 建議的所有入口網站私有雲安裝作業,都必須將入口網站置於負載平衡器後方。因此,您必須在負載平衡器上設定 TLS,而不是在入口網站上設定。因此,設定 TLS 的程序取決於負載平衡器。

不過,如有需要,您可以在託管入口網站的網路伺服器上設定 TLS。

如要概略瞭解如何在入口網站上使用 TLS,請參閱「在入口網站上使用 TLS」。

在 Apache 上執行的入口網站

如果入口網站安裝作業使用 Apache 網路伺服器:

  1. 取得 TLS 金鑰和憑證。
  2. 請務必安裝 mod_ssl:
    > yum install mod_ssl
  3. Updating /etc/httpd/conf/httpd.conf:
    1. 如要停用通訊埠 80 的 HTTP 存取權,請搜尋「Listen 80」並將其註解掉。
    2. 在檔案結尾加入下列幾行:
      LoadModule ssl_module modules/mod_ssl.so
      Listen 443
  4. 編輯 /etc/httpd/conf/vhosts/devportal.conf,新增下列內容來設定虛擬主機:
    <VirtualHost *:443>
    ServerName localhost
    SSLEngine on
    SSLCertificateFile "<public cert path>"
    SSLCertificateKeyFile "<private key path>"
    DocumentRoot "/var/www/html"
    <Directory "/var/www/html">
    Options Indexes FollowSymLinks MultiViews
    AllowOverride All
    Order allow,deny
    Allow from all
    </Directory>
    </VirtualHost>


    此外,如果您不想使用 HTTP,請將現有的 VirtualHost 定義註解排除。
  5. 由於 TLS 是在 httpd.conf 中設定,因此您不需要 ssl.conf:
    > mv /etc/httpd/conf.d/ssl.conf /etc/httpd/conf.d/ssl.conf.orig
  6. 重新啟動 Apache:
    > service httpd restart
    系統可能會提示您輸入金鑰檔案的密碼。

您應該可以透過 TLS 存取入口網站。

在 Nginx 上執行的入口網站

根據預設,使用 Nginx 網路伺服器的入口網站會監聽通訊埠 8079 上的 HTTP 要求。如果啟用 TLS,入口網站只會監聽 8079 上的 HTTPS 要求。也就是說,您可以將入口網站設為監聽 HTTP 要求或 HTTPS 要求,但不能同時監聽兩者。

您也可以按照「設定入口網站使用的 HTTP 通訊埠」一節所述,變更通訊埠號碼。

如果入口網站安裝作業使用 Nginx 網路伺服器:

  1. 取得 TLS 金鑰和憑證。在本範例中,憑證位於名為 server.crt 的檔案中,金鑰則位於 server.key。
  2. 將憑證和金鑰上傳至入口網站伺服器的 /opt/apigee/customer/nginx/ssl。
  3. 將憑證和金鑰的擁有者變更為「apigee」使用者:
    > chown apigee:apigee /opt/apigee/customer/nginx/ssl/server.crt
    > chown apigee:apigee /opt/apigee/customer/nginx/ssl/server.key
  4. 在編輯器中開啟 /opt/apigee/customer/application/drupal-devportal.properties。如果檔案和目錄不存在,請建立。
  5. 在 drupal-devportal.properties 中設定下列屬性:
    conf_devportal_ssl_block=ssl on; ssl_certificate /opt/apigee/customer/nginx/ssl/server.crt; ssl_certificate_key /opt/apigee/customer/nginx/ssl/server.key;
    conf_devportal_http_https_redirect=
    conf_devportal_fastcgi_https=fastcgi_param HTTPS on; fastcgi_param HTTP_SCHEME https;

    針對 conf_devportal_ssl_block,指定憑證和金鑰檔案的路徑。您不需要修改其他屬性。
  6. 儲存檔案。
  7. 重新啟動入口網站:
    /opt/apigee/apigee-service/bin/apigee-service apigee-drupal-devportal restart

您應該可以透過 TLS 存取入口網站。