Apache 리버스 프록시를 사용하여 설치하고 싶습니다

Apache의 리버스 프록시를 사용하여 설치하려고 하고 커스텀 포트와 함께 설치를 시도했지만 작동하지 않았습니다.
이 작업을 수행할 수 있는 방법이 있을까요?

Checking your domain name . . .
WARNING: Port 443 of computer does not appear to be accessible using hostname:  
DOMAIN-NAME
WARNING: Connection to DOMAIN-NAME (port 80) also fails.

This suggests that DOMAIN-NAME resolves to some IP address that does not reach this 
machine where you are installing discourse.

The first thing to do is confirm that DOMAIN-NAME resolves to the IP address of this server.
You usually do this at the same place you purchased the domain.

If you are sure that the IP address resolves correctly, it could be a firewall issue.
A web search for "open ports YOUR CLOUD SERVICE" might help.

This tool is designed only for the most standard installations. If you cannot resolve
the issue above, you will need to edit containers/app.yml yourself and then type

FAILED
--------------------
Pups::ExecError: /usr/local/bin/ruby -e 'if ENV["DISCOURSE_HOSTNAME"] == "discourse.example.com"; puts "Aborting! Domain is not configured!"; exit 1; end' failed with return #<Process::Status: pid 176 exit 1>
Location of failure: /pups/lib/pups/exec_command.rb:112:in `spawn'
exec failed with the params "/usr/local/bin/ruby -e 'if ENV[\"DISCOURSE_HOSTNAME\"] == \"discourse.example.com\"; puts \"Aborting! Domain is not configured!\"; exit 1; end'"
de0d133ffdd4c51d9a870d09bd16ce8fcc0680130ced1446f0038b4175a46840
** FAILED TO BOOTSTRAP ** please scroll up and look for earlier error messages, there may be more than one.
./discourse-doctor may help diagnose the problem.

app.yml

## which TCP/IP ports should this container expose?
## If you want Discourse to share a port with another webserver like Apache or nginx,
## see https://meta.discourse.org/t/17247 for details
expose:
  - "127.0.0.1:8100:80"   # http

params:

discourse-setup을 사용할 수는 없지만, 다음을 검색할 수 있습니다: 기존 Apache 사이트가 있는 서버에서 Discourse 설정하는 방법

감사합니다.
가이드를 따라 Discourse를 구축했습니다.
하지만 Apache의 리버스 프록시가 제대로 작동하지 않습니다.

    ProxyPass /  ws://var/discourse/shared/standalone/nginx.http.sock
    ProxyPassReverse / ws://var/discourse/shared/standalone/nginx.http.sock

오류

 No protocol handler was valid for the URL /favicon.ico (scheme 'ws'). If you are using a DSO version of mod_proxy, make sure the proxy submodules are included in the configuration using LoadModule., 

@Teraterayuki 님, 안녕하세요.

Discourse 컨테이너의 유닉스 도메인 소켓으로 리버스 프록싱하기 위한 작동하는 Apache2 가상 호스트 설정 예시를 아래에 드립니다:

포트 80

<VirtualHost *:80>
        ServerName mysite.mydomain.com
        ServerAdmin webmaster@localhost
        ProxyPreserveHost On

        #ProxyPass / http://127.0.0.1:8888/
        #ProxyPassReverse / http://127.0.0.1:8888/

        # Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
        # error, crit, alert, emerg.
        # It is also possible to configure the loglevel for particular
        # modules, e.g.
        #LogLevel info ssl:warn

        ErrorLog ${APACHE_LOG_DIR}/community_errors.log
        CustomLog ${APACHE_LOG_DIR}/community.log combined

        # For most configuration files from conf-available/, which are
        # enabled or disabled at a global level, it is possible to
        # include a line for only one particular virtual host. For example the
        # following line enables the CGI configuration for this host only
        # after it has been globally disabled with "a2disconf".
        #Include conf-available/serve-cgi-bin.conf
        ModPagespeed Off
        RewriteEngine on
        RewriteCond %{SERVER_NAME} =mysite.mydomain.com
        RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>

포트 443

<IfModule mod_ssl.c>
<VirtualHost *:443>
        ServerName mysite.mydomain.com
        ServerAdmin webmaster@localhost
        #SSLProxyEngine on   #enable this after Let's encrypt is setup on the reverse proxy
  	    RewriteEngine On
        
        RewriteCond %{HTTP_USER_AGENT}  (Bytespider|Yandex|Wget|seocompany|CCBot|Cincraw) [NC]
        RewriteRule . - [R=403,L]

  	    ProxyPreserveHost On
  	    ProxyRequests Off
  	    RequestHeader set X-Forwarded-Proto expr=%{REQUEST_SCHEME}
 	    RequestHeader set X-Real-IP expr=%{REMOTE_ADDR}

        #ProxyPass / http://127.0.0.1:8888/
        #ProxyPassReverse / http://127.0.0.1:8888/
        ProxyPass / unix:/var/discourse/shared/socket-only/nginx.http.sock|http://localhost/
        ProxyPassReverse  / unix:/var/discourse/shared/socket-only/nginx.http.sock|http://localhost/

        # Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
        # error, crit, alert, emerg.
        # It is also possible to configure the loglevel for particular
        # modules, e.g.
        #LogLevel info ssl:warn

        ErrorLog ${APACHE_LOG_DIR}/community_errors_ssl.log
        #CustomLog ${APACHE_LOG_DIR}/community_ssl.log combined

        # For most configuration files from conf-available/, which are
        # enabled or disabled at a global level, it is possible to
        # include a line for only one particular virtual host. For example the
        # following line enables the CGI configuration for this host only
        # after it has been globally disabled with "a2disconf".
        #Include conf-available/serve-cgi-bin.conf
        ModPagespeed Off
        SSLCertificateFile /etc/letsencrypt/live/mysite.mydomain.com/fullchain.pem
        SSLCertificateKeyFile /etc/letsencrypt/live/mysite.mydomain.com/privkey.pem
        Include /etc/letsencrypt/options-ssl-apache.conf
</VirtualHost>
</IfModule>

@Teraterayuki

이 설정에서 프록시는 웹 소켓(ws)이 아니라 유닉스 소켓으로 연결된다는 점을 유의해 주세요.

또한 이 설정에서는 Let’s Encrypt 정보를 수동으로 추가할 필요가 없습니다. 다음으로 시작할 수 있습니다:

Certbot 실행 전 포트 80

<VirtualHost *:80>
        ServerName mysite.mydomain.com
        ServerAdmin webmaster@localhost
        ProxyPreserveHost On

        #ProxyPass / http://127.0.0.1:8888/
        #ProxyPassReverse / http://127.0.0.1:8888/

        # Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
        # error, crit, alert, emerg.
        # It is also possible to configure the loglevel for particular
        # modules, e.g.
        #LogLevel info ssl:warn

        ErrorLog ${APACHE_LOG_DIR}/community_errors.log
        CustomLog ${APACHE_LOG_DIR}/community.log combined

        # For most configuration files from conf-available/, which are
        # enabled or disabled at a global level, it is possible to
        # include a line for only one particular virtual host. For example the
        # following line enables the CGI configuration for this host only
        # after it has been globally disabled with "a2disconf".
        #Include conf-available/serve-cgi-bin.conf
        ModPagespeed Off
     
</VirtualHost>

Certbot 실행 전 포트 443

<IfModule mod_ssl.c>
<VirtualHost *:443>
        ServerName mysite.mydomain.com
        ServerAdmin webmaster@localhost
        #SSLProxyEngine on   #enable this after Let's encrypt is setup on the reverse proxy
  	    RewriteEngine On
        


  	    ProxyPreserveHost On
  	    ProxyRequests Off
  	    RequestHeader set X-Forwarded-Proto expr=%{REQUEST_SCHEME}
 	    RequestHeader set X-Real-IP expr=%{REMOTE_ADDR}

        #ProxyPass / http://127.0.0.1:8888/
        #ProxyPassReverse / http://127.0.0.1:8888/
        ProxyPass / unix:/var/discourse/shared/socket-only/nginx.http.sock|http://localhost/
        ProxyPassReverse  / unix:/var/discourse/shared/socket-only/nginx.http.sock|http://localhost/

        # Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
        # error, crit, alert, emerg.
        # It is also possible to configure the loglevel for particular
        # modules, e.g.
        #LogLevel info ssl:warn

        ErrorLog ${APACHE_LOG_DIR}/community_errors_ssl.log
        #CustomLog ${APACHE_LOG_DIR}/community_ssl.log combined

        # For most configuration files from conf-available/, which are
        # enabled or disabled at a global level, it is possible to
        # include a line for only one particular virtual host. For example the
        # following line enables the CGI configuration for this host only
        # after it has been globally disabled with "a2disconf".
        #Include conf-available/serve-cgi-bin.conf
        ModPagespeed Off

</VirtualHost>
</IfModule>

그 다음, 다음 명령을 실행하면:

certbot -d mysite.mydomain.com

친절한 certbot이 필요한 SSL 코드를 자동으로 추가해 줍니다.

certbot이 설정 코드를 추가하고 모든 것이 예상대로 작동하는 것을 확인한 후, 다음 줄의 주석을 해제할 수 있습니다:

#SSLProxyEngine on   #enable this after Let's encrypt is setup on the reverse proxy

그리고 apache2를 다시 시작하세요.

@Teraterayuki 님께 도움이 되기를 바랍니다.

건강하세요.


마무리 노트:

  1. Apache2 리버스 프록시 설정에서 haproxy를 사용하지 않는다는 점을 유의해 주세요. haproxy는 (우리에게) 실질적인 이점이 거의 없으면서 불필요한 복잡성을 더합니다. 따라서 우리는 리버스 프록시로 apache2를 "간편한 방법"으로 실행합니다. haproxy를 사용하려는 경우 결과는 다를 수 있습니다(YMMV). 하지만 솔직히 말하면, 우리는 (프로덕션 환경의 여러 Apache2 리버스 프록시 설정에서) haproxy를 사용하지 않으며, 리버스 프록시로 apache2를 사용하는 데 결코 문제가 없었습니다.
  1. mod_pagespeed를 사용하지 않는 경우 해당 줄들을 주석 처리하세요. 하지만 mod_pagespeed를 실행 중이라면, Discourse로 리버스 프록싱할 때 가상 호스트별로 mod_pagespeed를 꺼야 합니다.

최선을 다해 돕고자 합니다. 조금이라도 도움이 되기를 바랍니다.

완료했습니다.
감사합니다!
실제로 설정한 내용은 다음과 같습니다!

<VirtualHost *:80>
  ServerName DOMAIN-NAME
    ProxyPreserveHost on
    RequestHeader set X-Forwarded-Proto expr=%{REQUEST_SCHEME}
    RequestHeader set X-Real-IP expr=%{REMOTE_ADDR}
    ProxyPass / unix:/var/discourse/shared/standalone/nginx.http.sock|http://localhost/
    ProxyPassReverse  / unix:/var/discourse/shared/standalone/nginx.http.sock|http://localhost/
</VirtualHost>

환영합니다!

얼마나 쉬운지 보세요.

Discourse용 Apache2를 리버스 프록시로 설정하는 것은 https 없이 단순한 포트 80 설정으로 보여주신 것처럼 매우 간단합니다. 잘하셨습니다 :slight_smile:

또한 https를 통해 사이트에 성공적으로 액세스했습니다.
그리고 https로 리다이렉트하도록 리버스 프록시 apache를 설정했습니다.
그러나 리소스는 http를 통해 액세스되는 것으로 보이며 올바르게 표시되지 않는 것 같습니다.
어떻게 하면 될까요?

가상 호스트의 작동하는 설정 파일을 게시해야 합니다. 게시하지 않으면 아무도 그 내용을 볼 수도, 도움을 줄 수도 없으니까요 :slight_smile:

참고로, 여러분이 시도하고 있는 동일한 구성에 대해 완전히 작동하는(프로덕션 환경) 가상 호스트 설정 파일을 이미 게시한 적이 있습니다. 이 파일들을 이해하고 따라 하신다면 아무런 문제가 없어야 합니다 :wink:

이렇게 설정했습니다.
Discourse가 생성하는 모든 URL이 http인 것 같습니다.

<VirtualHost *:80>
  ServerName DOMAIN-NAME
  RewriteEngine on
  RewriteCond %{HTTPS} off
  RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
</VirtualHost>
<VirtualHost *:443>
  ServerName DOMAIN-NAME
  SSLEngine On
  SSLProtocol all -SSLv2
  SSLCertificateFile /etc/letsencrypt/live/DOMAIN-NAME/fullchain.pem
  SSLCertificateKeyFile /etc/letsencrypt/live/DOMAIN-NAME/privkey.pem
  ProxyPreserveHost on
  RequestHeader set X-Forwarded-Proto expr=%{REQUEST_SCHEME}
  RequestHeader set X-Real-IP expr=%{REMOTE_ADDR}
  ProxyPass / unix:/var/discourse/shared/standalone/nginx.http.sock|http://localhost/
  ProxyPassReverse  / unix:/var/discourse/shared/standalone/nginx.http.sock|http://localhost/
</VirtualHost>

DISCOURSE_FORCE_HTTPS를 true로 정의하거나 시스템 설정에서 해당 옵션을 설정해야 합니다.

안녕하세요! discourse-setup 스크립트는 포트 80/443이 사용 중인 경우 이 페이지로 안내하지만, 이 지침은 신규 설치에는 적용되지 않습니다. 자체 리버스 프록시를 사용하여 신규 설치를 진행하는 방법은 무엇인가요?

이렇게 시도해 보세요:

./discourse-setup  --skip-connection-test --skip-rebuild

그 후에도 app.yml 파일을 수동으로 편집해야 하지만, 적어도 프롬프트로 요청하는 항목들은 채워 넣을 것입니다.

이 방법이 도움이 되는지 알려 주시면, 해당 howto 문서를 그에 맞게 수정할 수 있도록 하겠습니다.

HTTP_PORT와 HTTPS_PORT를 변수로 사용하도록 스크립트를 수정했습니다. 하지만 이 값이 사라질 수 있으므로 깔끔한 해결책은 아닙니다. 게시글에 이 내용을 언급해 주시면 첫 설치 시 도움이 될 것 같습니다 :slight_smile:

app.yml 파일을 수정한 건가요? 언제 사라질 거라고 생각하시나요?