VPS의 웹 앱. 하위 도메인에 표시하려면 어떻게 해야 합니까?

VPS의 웹 앱. 하위 도메인에 표시하려면 어떻게 해야 합니까?

저는 개인 VPS(Ubuntu 20, Apache2)를 사용하여 웹 앱을 호스팅하고 있습니다. 현재 site1.com과 site2.org라는 2개의 정적 사이트가 있으며 둘 다 작동하고 있습니다.

현재 포트 8065에서 사용할 수 있는 앱을 설치했습니다. 예:site2.org:8065

내 질문은 앱이 다음에 표시되도록 Apache를 어떻게 설정합니까?mm.site2.org? (하위 도메인 "mm" 사용).

다음과 같은 구성 파일을 만들었습니다.

# /etc/apache2/sites-available/mm.site2.org.conf
<VirtualHost *:80>
    ServerName mm.site2.org

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined


    ProxyRequests Off
    <Proxy http://localhost:8065/*>       
      Order deny,allow
      Allow from all
    </Proxy>
        
    ProxyPass / http://127.0.0.1:8065/
    ProxyPassReverse / http://127.0.0.1:8065/

    <Location />
      Order allow,deny
      Allow from all
    </Location>

</VirtualHost>

위의 설정을 마친 후 다음과 같이 서비스를 다시 시작하기 위해 필수 명령을 실행했습니다.

sudo a2ensite mm.site2.org.conf
sudo systemctl reload apache2
sudo service apache2 restart

<Proxy ...>또한 일부 소스에서 제안하는 대로 간단히 사용하여 일부 다른 소스를 기반으로 Apache conf 파일의 행 변형을 시도했습니다 <Proxy *>.

관련이 있는 경우 내 DNS 설정은 각 사이트에 대한 두 개의 A 레코드( @www)로 구성됩니다.

출력은 다음과 sudo apache2ctl -S같습니다.

AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 12.345.67.890. Set the 'ServerName' directive globally to suppress this message
VirtualHost configuration:
*:443                  is a NameVirtualHost
         default server site1.com (/etc/apache2/sites-enabled/site1.com-le-ssl.conf:2)
         port 443 namevhost site1.com (/etc/apache2/sites-enabled/site1.com-le-ssl.conf:2)
                 alias www.site1.com
         port 443 namevhost site2.org (/etc/apache2/sites-enabled/site2.org-le-ssl.conf:2)
                 alias www.site2.org
*:80                   is a NameVirtualHost
         default server 12.345.67.890 (/etc/apache2/sites-enabled/000-default.conf:1)
         port 80 namevhost 12.345.67.890 (/etc/apache2/sites-enabled/000-default.conf:1)
         port 80 namevhost site1.com (/etc/apache2/sites-enabled/site1.com.conf:1)
                 alias www.site1.com
         port 80 namevhost site2.org (/etc/apache2/sites-enabled/site2.org.conf:1)
                 alias www.site2.org
ServerRoot: "/etc/apache2"
Main DocumentRoot: "/var/www/html"
Main ErrorLog: "/var/log/apache2/error.log"
Mutex default: dir="/var/run/apache2/" mechanism=default 
Mutex watchdog-callback: using_defaults
Mutex rewrite-map: using_defaults
Mutex ssl-stapling-refresh: using_defaults
Mutex ssl-stapling: using_defaults
Mutex proxy: using_defaults
Mutex ssl-cache: using_defaults
PidFile: "/var/run/apache2/apache2.pid"
Define: DUMP_VHOSTS
Define: DUMP_RUN_CFG
User: name="www-data" id=33
Group: name="www-data" id=33

원하는 하위 도메인에 웹앱이 표시되도록 하는 것은 운이 좋지 않습니다.

답변1

작성하신 내용에 따르면 DNS가 제대로 구성되지 않은 것 같습니다.

관련이 있는 경우 내 DNS 설정은 각 사이트에 대해 두 개의 A 레코드(@ 및 www)로 구성됩니다.

mm.site2.org. A 12.345.67.890하위 도메인, address: 또는 cname(별칭): 에 대해 DNS RR을 추가해야 합니다 mm.site2.org. CNAME www.site2.org.. 모든 하위 도메인을 이 서버로 지정하려면 RR 이름을 와일드카드로 사용할 수 있습니다. *.site2.org. A 12.345.67.890(CNAME RR로도 충분할 것입니다.) (이미 이렇게 작동할 것으로 예상한 것 같습니다.)

관련 정보