나는 여기서 뭔가 어려움을 겪고 있습니다. Azure + Apache2에 Ubuntu 18.04 VM이 설치되어 있습니다. 내 VM의 웹 서버 /var/www/를 가리키는 도메인(example.com)이 있고 최근 SSL을 설정하여 서버를 보호했습니다. 모든 HTTP 트래픽을 HTTPS로 리디렉션하는 옵션을 선택하여 letsencrypt 및 "certbot"을 사용하여 인증서를 받았습니다. 내 사이트의 .conf는 다음과 같습니다.
root@wp-vm:/# cat /etc/apache2/sites-available/example.com.conf
<VirtualHost *:80>
ServerAdmin webmaster@localhost
ServerName example.com
ServerAlias www.example.com
DocumentRoot /var/www/example.com
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
<Directory /var/www/example.com/>
AllowOverride All
</Directory>
RewriteEngine on
RewriteCond %{SERVER_NAME} =www.example.com [OR]
RewriteCond %{SERVER_NAME} =example.com
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>
동일한 서버에서 RStudio Shiny 서버(포트 3838) 및 Rstudio Server IDE 오픈 소스(8787) 등 다른 웹 서비스를 실행하고 있습니다. SSL이 옵션이 아닌 무료 버전입니다. 이제 SSL을 사용하는 웹 서버에서는 iframe을 통해 빛나는 서버의 콘텐츠를 웹 페이지(워드프레스)에 삽입할 수 없다는 것을 알게 되었습니다. 따라서 이전에는 example.com:3838/app에 연결할 수 있었지만 포트를 보호할 때까지는 더 이상 작동하지 않습니다.
다음을 어떻게 달성합니까?
http(s)://example.com >> webserver (OK)
http(s)://example.com:48787 >> rstudio @ 8787
http(s)://example.com:43838 >> shiny @ 3838
또는더 나은, 다음과 같은 하위 도메인으로 어떻게 설정합니까(복잡성이 너무 많이 추가되지 않는 경우):
http(s)://example.com >> apache webserver @ /var/www (OK)
http(s)://rstudio.example.com >> rstudio @ 8787
http(s)://shiny.example.com >> shiny @ 3838
명확하게 말하면 브라우저는 HTTPS를 통해 통신해야 하지만 8787/3838의 서비스는 HTTP로 유지됩니다.
이미 시도했지만 제대로 작동하지 않은 것 중 일부는 ProxyPass 및 ProxyPassReverse를 사용하여 여러 모듈을 로드하고 가상 호스트를 다양한 방법으로 정의하고 "Location"/subdomain 태그를 사용하여 기존 가상 호스트를 수정해 보았습니다. 나는 아파치에게 ports.conf의 새 포트를 수신하라고 지시하고 방화벽(azure 및 ufw)을 열었습니다. 나는 분명히 뭔가를 놓치고 있지만 무엇을 모릅니다. 현재 방화벽은 다음과 같습니다. 답변에 도움이 될 수 있는 추가 정보를 알려주세요.
root@wp-vm:/# ufw status numbered
Status: active
To Action From
-- ------ ----
[ 1] Apache Full ALLOW IN Anywhere
[ 2] 3838 ALLOW IN Anywhere
[ 3] 8787 ALLOW IN Anywhere
[ 4] 43838 ALLOW IN Anywhere
[ 5] 48787 ALLOW IN Anywhere
[ 6] 22/tcp ALLOW IN Anywhere
[ 7] Apache Full (v6) ALLOW IN Anywhere (v6)
[ 8] 3838 (v6) ALLOW IN Anywhere (v6)
[ 9] 8787 (v6) ALLOW IN Anywhere (v6)
[10] 43838 (v6) ALLOW IN Anywhere (v6)
[11] 48787 (v6) ALLOW IN Anywhere (v6)
[12] 22/tcp (v6) ALLOW IN Anywhere (v6)
아파치
root@wp-vm:/# apache2 -v
Server version: Apache/2.4.29 (Ubuntu)
Server built: 2020-08-12T21:33:25
편집/업데이트: 중요한 파일의 내용을 빠뜨렸고, 아마도 이번에도 잘못된 파일(example.com.conf)을 조작하고 있었을 것입니다.
root@wp-vm:/etc/apache2/sites-available# cat example.com-le-ssl.conf
<IfModule mod_ssl.c>
<VirtualHost *:443>
ServerAdmin webmaster@localhost
ServerName example.com
ServerAlias www.example.com
DocumentRoot /var/www/example.com
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
<Directory /var/www/example.com/>
AllowOverride All
</Directory>
Include /etc/letsencrypt/options-ssl-apache.conf
SSLCertificateFile /etc/letsencrypt/live/example.com/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/example.com/privkey.pem
</VirtualHost>
</IfModule
그래서 example.com.conf 파일은 단순히 모든 요청을 https로 다시 작성하고 443으로 리디렉션한다고 생각하므로 그대로 둡니다. 이제 이것을 ssl conf 파일에 추가하려고 시도했지만 운이 없습니다. 이 파일의 모든 것을 다시 시도할 것 같습니다..
ProxyRequests off
ProxyPass /shiny/ http://localhost:3838/
ProxyHTMLURLMap http://localhost:3838 /shiny
<Location /shiny/>
ProxyPassReverse /
ProxyHTMLEnable On
ProxyHTMLURLMap / /shiny/
RequestHeader unset Accept-Encoding
</Location>
편집 #2 가까이서 맛볼 수 있을 정도! 기본적으로 하위 디렉터리(example.com/shiny 및 /rstudio)를 사용하여 작업하고 있습니다. 그러나 주소를 입력하는 방법은 까다롭습니다. 마지막 뒤에 "/"가 포함되고 "https"가 포함되는지 여부는 매우 까다롭습니다.
이 사람은 rstudio와 비슷한 문제를 겪고 있는 것 같았습니다.그리고 여러 번 다시 작성하고 리디렉션하여 문제를 '해결'했습니다("리소스 제한 설정" 섹션 직전에 최종 솔루션까지 아래로 스크롤). 이는 "루트" 경로에서는 작동하지만 /shiny 아래의 응용 프로그램 하위 디렉터리에서는 작동하지 않습니다. 따라서 example.com/shiny/는 작동하고 example.com/shiny는 ../shiny/로의 리디렉션을 통해 작동하지만 example.com/shiny/app1은 작동하지 않고 /app1로 확인됩니다. example.com/shiny/app1/을 입력해야 합니다.
지금은 /shiny와 /rstudio 모두에 대해 동일한 작업을 수행했습니다. 여기 내 현재 .conf가 있습니다. 내 문제와 질문은 이제 '/' 생략에 대해 깨끗하고 정확하며 견고하게 만드는 방법으로 축소되었다고 생각합니다.
root@wp-vm:/etc/apache2/sites-available# cat *-le*
<IfModule mod_ssl.c>
<VirtualHost *:443>
ServerAdmin webmaster@localhost
ServerName example.com
ServerAlias www.example.com
DocumentRoot /var/www/example.com
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
<Directory /var/www/example.com/>
AllowOverride All
</Directory>
Include /etc/letsencrypt/options-ssl-apache.conf
SSLCertificateFile /etc/letsencrypt/live/example.com/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/example.com/privkey.pem
SSLProxyEngine On
# extra redirect for shiny subdirectory
Redirect /shiny /shiny/
# extra redirects for the RStudio subdirectory
Redirect /rstudio /rstudio/
Redirect /auth-sign-in /rstudio/auth-sign-in
Redirect /auth-sign-out /rstudio/auth-sign-out
# Catch RStudio redirecting improperly from the auth-sign-in page
<If "%{HTTP_REFERER} =~ /auth-sign-in/">
RedirectMatch ^/$ /rstudio/
</If>
##
ProxyRequests Off
ProxyPreserveHost On
<Proxy *>
AddDefaultCharset Off
Order deny,allow
Allow from all
</Proxy>
ProxyPass /shiny/ http://127.0.0.1:3838/
ProxyPassReverse /shiny/ http://127.0.0.1:3838/
ProxyPass /rstudio/ http://localhost:8787/
ProxyPassReverse /rstudio/ http://localhost:8787/
##
RequestHeader set X-Forwarded-Proto "https"
##
</VirtualHost>
</IfModule>