Create Separate DB for Subdomain(Vhost)

Discussion in 'ISPConfig 3 Priority Support' started by yupthatguy, Oct 4, 2021.

  1. yupthatguy

    yupthatguy Member HowtoForge Supporter

    I create a git.example.com/gitea as subdomain as vhost. However, under databases, the drop-down doesn't include "git.example.com/gitea"

    So my question is how do I create the db for the subdomain?
     
  2. till

    till Super Moderator Staff Member ISPConfig Developer

    A subdomain vhost belongs to a website, it is not a website on its own and a database belongs also to a website. Therefore, you select the website where this vhost subdomain belongs when you create a database.
     
  3. yupthatguy

    yupthatguy Member HowtoForge Supporter

    I've done that... and now I have tried both variants of the gitea documentation apache reverse-proxy settings
    Code:
      ProxyPreserveHost On
        ProxyRequests off
        AllowEncodedSlashes NoDecode
        SSLProxyEngine on
        ProxyPass /.well-known !
        ProxyPass / http://127.0.0.1:3000/ nocanon
        ProxyPassReverse / http://127.0.0.1:3000/
       
       
       -or-
    
        <Proxy *>
             Order allow,deny
             Allow from all
        </Proxy>
        AllowEncodedSlashes NoDecode
        # Note: no trailing slash after either /git or port
        ProxyPass / http://127.0.0.1:3000 nocanon
        ProxyPassReverse / http://127.0.0.1:3000
    
    both result in a 500 server error...
    so I removed the apache directives from the options page... and disabled proxy... interestingly, I get a 404 error stating that
    https://git.example.com/gitea doesn't exist. I was expecting the default green "welcome to your site" message.
     
  4. till

    till Super Moderator Staff Member ISPConfig Developer

    Check the error.log and the gitea log to see if gitea throws the 500 error or if apache throws it and check which the exact error message is that you get in the log.
     
  5. yupthatguy

    yupthatguy Member HowtoForge Supporter

    I need to run an errand before I check the other logs, but apache error log has one error
    [Mon Oct 04 17:49:04.240411 2021] [:error] [pid 18198] avahi_entry_group_add_service_strlst("server1") failed: Local name collision
    [Mon Oct 04 17:49:04.241945 2021] [:error] [pid 18198] avahi_entry_group_add_service_strlst("server1") failed: Local name collision
     
  6. yupthatguy

    yupthatguy Member HowtoForge Supporter

    With subdomain(vhost) -> options -> proxy enable using the apache directive below for the reverse proxy

    Code:
    ProxyPreserveHost On
        ProxyRequests off
        AllowEncodedSlashes NoDecode
        SSLProxyEngine on
        ProxyPass / http://127.0.0.1:3000/ nocanon
        ProxyPassReverse / http://127.0.0.1:3000/
    
    I get a 500 server error:
    gitea log is empty
    /var/lib/gitea/log

    checking the site error log:

    Code:
    #cat /var/log/ispconfig/httpd/git.example.com/error.log
    Mon Oct 04 19:18:07.798332 2021] [proxy:warn] [pid 2930] [client 40.387.652.176:52522] AH01144: No protocol handler was valid for the URL /gitea (scheme 'http'). If you are using a DSO version of mod_proxy, make sure the proxy submodules are included in the configuration using LoadModule.
    [Mon Oct 04 19:18:07.800696 2021] [proxy:warn] [pid 2930] [client 40.387.652.176:52522] AH01144: No protocol handler was valid for the URL /error/500.html (scheme 'http'). If you are using a DSO version of mod_proxy, make sure the proxy submodules are included in the configuration using LoadModule.
    
    The apache error log doesn't show any relevant error, the only error is the showing that I haven't, whitelisted my monit url on my prod server yet.
     
  7. yupthatguy

    yupthatguy Member HowtoForge Supporter

    I enabled the missing submodules...(below), but ran into a new 500 server error
    Code:
    #a2enmod module proxy_http
    #a2enmod proxy_balancer
    
    Code:
    AH00898: Error during SSL Handshake with remote server returned by /error/500.html
    AH01097: pass request body failed to 127.0.0.1:3000 (127.0.0.1) from
    40.387.652.176 ()
    
    Didn't see a quick fix for this... any tips?
     
    Last edited: Oct 4, 2021
  8. yupthatguy

    yupthatguy Member HowtoForge Supporter

    cracked it!

    a bit of trial & error
    but using

    Code:
    ProxyPreserveHost On
        ProxyRequests off
        AllowEncodedSlashes NoDecode
        SSLProxyEngine on
        ProxyPass /.well-known !
        ProxyPass / http://localhost:3000/ nocanon
        ProxyPassReverse / http://localhost:3000/
    
    seems to solve the problem (I literally exchange 127.0.0.1 for localhost, which I advised against doing in a different forum)

    now https://git.example.com/gitea sends me to https://git.example.com and displays the gitea installation page.

    I haven't tried the install yet.. but looks good.
     
  9. yupthatguy

    yupthatguy Member HowtoForge Supporter

    'twas a short lived victory. The install went sideways...
    the login page should have loaded following the install, instead I was taken to

    https://git.example.com/git.example.com/user/login

    with these errors:
    Code:
    AH00957: HTTP: attempt to connect to 127.0.0.1:3000 (localhost) failed
    AH01114: HTTP: failed to make connection to backend: localhost
    

    anyway will revert to these directives:
    Code:
    ProxyPreserveHost On
       ProxyRequests off
       AllowEncodedSlashes NoDecode
       SSLProxyEngine on
       ProxyPass /.well-known !
       ProxyPass / http://127.0.0.1:3000/ nocanon
       ProxyPassReverse / http://127.0.0.1:3000/
    
    and call it a night... tips.. welcome
     
  10. yupthatguy

    yupthatguy Member HowtoForge Supporter

    Ok.. I am back on test server... I have a basic question:

    I have the subdomain vhost git.example.com with web folder "gitea".
    so I ssh into the server and copied the standard_index.html into "gitea"

    But instead of seeing the index.html, the browser shows the default home of the wp site located at example.com.

    How do I fix this?
     
  11. yupthatguy

    yupthatguy Member HowtoForge Supporter

    Actually, figured it out... I put apache into debug mode... and ran apache2ctl -S which showed that my alias for git.example.com wasn't being recognized.

    is it impossible to add an alias to subdomain vhost? i.e. (test.git.example.com)

    Via the gui.. it says I successfully created that alias, but apache denies it.

    [​IMG]
     
    Last edited: Oct 5, 2021
  12. till

    till Super Moderator Staff Member ISPConfig Developer

    Check the /etc/apache2/sites-available/ folder, is there a config file with .err file ending for this vhost? If yes, then you entered an invalid config in the apache directives tab of the website which was rejected by Apache, and therefore the system had to use the last working config, which also means that further config changes like adding an additional domain can't work as well until you fix the issue in the custom config in apache directives.
     
  13. yupthatguy

    yupthatguy Member HowtoForge Supporter

    I just checked... not there isn't .err version for this subdomain vhost.
     
  14. yupthatguy

    yupthatguy Member HowtoForge Supporter

    Whats happening is that tester1.git.example.com is "reverting" to tester1.example.com... but no .err vhost is being generated.
    Whereas if I go to git.example.com I get the proper landing page.

    Not a huge problem.. but I want to avoid missteps between prod and test, hence I always use a "tester1." domain alias locally.
     
  15. till

    till Super Moderator Staff Member ISPConfig Developer

    Ok, just checked this in ISPconfig and there is not even an option in ISPConfig to add an alias domain to a vhost subdomain, which you claimed exists as you claimed that you added it. So I wonder how did you add it as you must have modified ISPCopnfig source code to do that. Alias domains can be added to websites only in a standard ISPConfig system.
     
  16. yupthatguy

    yupthatguy Member HowtoForge Supporter

    I think anyone who reads my bumbling posts can figure out that I am far from being a coder capable of editing source code... Seemed odd.. so I added the screenshot above.. :eek:

    As for steps.. I just added tester1.git.example.com in the top field and selected example.com from the drop-down.
     
  17. till

    till Super Moderator Staff Member ISPConfig Developer

    This means you added tester1.git.example.com as an alias domain to the website example.com and when you look into the vhost file of example.com, you will find it there. Not sure why you thought you added it to a host alias domain as vhost alias domains are not available as targets there at all.
     
  18. yupthatguy

    yupthatguy Member HowtoForge Supporter

    I don't work on this everyday... still climbing the learning curve from zero... I wanted tester1.git.example.com, so I typed that.. In any case, sorry for setting off any alarm bells... now I know.
     
  19. till

    till Super Moderator Staff Member ISPConfig Developer

    If you would have wanted to add other alias or subdomains to this git proxy vhost, then you should have added a new website git.example.com right at the beginning instead of adding a vhost alias domain. In general, vhost alias domains are not recommended to be used at all, there are only very rare cases when the installed software in the website is very limited in its configurability where you need such a workaround that vhost alias domains provide. Normally, you always add just a website, which is more secure than a vhost alias or subdomain anyway.
     
  20. till

    till Super Moderator Staff Member ISPConfig Developer

    I understand that. More generally spoken, if you want to have B as an alias for A, but A is not available in the list of targets for B when you create the alias, then this can't work.
     

Share This Page