Changes in plugin files

Discussion in 'Installation/Configuration' started by remkoh, Oct 27, 2024.

  1. remkoh

    remkoh Active Member HowtoForge Supporter

    I'm in need to make some changes in some files in the plugins folder.
    Is there a way to make changes that holdup when updating ISPConfig?
    Like with customized files in the conf-custom folder and config.inc.local.php for example?
     
  2. till

    till Super Moderator Staff Member ISPConfig Developer

    No, that's core code of ISPConfig. You should consider writing your own plugins if you need customizations instead of changing the core plugins.
     
  3. remkoh

    remkoh Active Member HowtoForge Supporter

    That's what I thought and expected the answer to be.
    Unfortunate for me but thanks @till
    Where's the Don't like button when you need it :D

    I was already searching for a workaround that doesn't include changing core code and do think that's possible in this case but will require a whole lot of research first from my side.
     
  4. remkoh

    remkoh Active Member HowtoForge Supporter

    I managed to work it out partly and added the desired customization.
    But I can't figure out where this line is coming from:
    Code:
    rewrite ^(?!/(\.well-known/acme-challenge))/(.*)$ https://domain2.tld/$2 redirect;
    It is a Nginx based webserver where I redirect vhost domain1.tld to domain2.tld using the redirect tab.
    File /usr/local/ispconfig/server/conf/nginx_vhost.conf.master only has 2 times "$2" in it and those lines aren't the source (local_redirects and own_redirects)
     
  5. till

    till Super Moderator Staff Member ISPConfig Developer

    That's the line to do that redirect. and $2 is the content of the second match of the rewrite regex, or in other words, $2 contains the URL part after the domain (its the match for (.*) in that line).
     
  6. remkoh

    remkoh Active Member HowtoForge Supporter

    Yes I know what it does, but where does it come from? I want to alter it a bit.
    I've looked at /usr/local/ispconfig/server/conf/nginx_vhost.conf.master and /usr/local/ispconfig/server/plugins-available/nginx_plugin.inc.php but can't find it.
     
  7. till

    till Super Moderator Staff Member ISPConfig Developer

    Is it not in the nginx vhost template file? if not, then it must be in the plugin, it might be that it is a string that is built consisting of several varaibles.
     
  8. remkoh

    remkoh Active Member HowtoForge Supporter

    That's where I would expect it but can't find it.
    There are several comparable lines, but all accompanied by if statements, which the mentioned line hasn't.
     
  9. till

    till Super Moderator Staff Member ISPConfig Developer

    It must be one of these two:

    Code:
    <tmpl_loop name="local_redirects">
            if ($http_host <tmpl_var name='local_redirect_operator'> "<tmpl_var name='local_redirect_origin_domain'>") {
                rewrite ^<tmpl_var name='local_redirect_exclude'>(.*)$ <tmpl_var name='local_redirect_target'>$2 <tmpl_var name='local_redirect_type'>;
            }
    </tmpl_loop>
    
    <tmpl_loop name="own_redirects">
    <tmpl_if name='use_rewrite'>
            <tmpl_if name='exclude_own_hostname'>if ($http_host != "<tmpl_var name='exclude_own_hostname'>") { </tmpl_if>rewrite ^<tmpl_var name='rewrite_exclude'>(.*)$ <tmpl_var name='rewrite_target'>$2 <tmpl_var name='rewrite_type'>;<tmpl_if name='exclude_own_hostname'> }</tmpl_if>
    </tmpl_if>
    probably the first one. To find the code in the plugin, search either for local_redirects or own_redirects.
     
  10. remkoh

    remkoh Active Member HowtoForge Supporter

    The first one already is altered to fit my needs.
    The second was my initial suspect but as you can see it too has an if statement accompanying the rewrite rule.
    The line in question in the generated vhost file hasn't.
     
  11. remkoh

    remkoh Active Member HowtoForge Supporter

    To clearify what I'm trying to accomplish is to add an exception for rewriting /.well-known/security.txt besides the default /.well-known/acme-challange (and other folders depending on the rewrite type).
     
  12. till

    till Super Moderator Staff Member ISPConfig Developer

    Search the plugin code for .well-known/acme-challenge, it must be in there somewhere. What you get as vhost file must be either in the template or in the code or in the database.
     
  13. remkoh

    remkoh Active Member HowtoForge Supporter

    Can you elaborate on the database part?
     
  14. till

    till Super Moderator Staff Member ISPConfig Developer

    A part of the rwrite is stored in the database, mainly the user input. see web_domain table.
     
  15. remkoh

    remkoh Active Member HowtoForge Supporter

    Only related things to find there are "redirect_path" and "redirect_type", which ofcourse got saved from within the panel, but not the rewrite itself.
     
  16. remkoh

    remkoh Active Member HowtoForge Supporter

    I should smack myself :eek:
    Completely misread the <tmpl_loop name="own_redirects"> part in /usr/local/ispconfig/server/conf/nginx_vhost.conf.master :oops:
     
  17. remkoh

    remkoh Active Member HowtoForge Supporter

    Managed to get it working for the most part.
    Except for rewriting to intenal url's.
    I can't find the variable containing the subfolder the rewrite points to, which I need for the rewrite exceptions.

    Also found a bug in nginx_plugin.inc.php while testing different configs and reported it.
     
    Taleman likes this.
  18. remkoh

    remkoh Active Member HowtoForge Supporter

    Sometimes all you need is half a good night sleep :D
    Just thought of another solution which will eliminate herefor struggle I mentioned and will keep /usr/local/ispconfig/server/conf/nginx_vhost.conf.master more original :cool:
    Going to give it a go later this afternoon.
     
    till likes this.
  19. remkoh

    remkoh Active Member HowtoForge Supporter

    Took a bit longer than I anticipated and a little help from a friend but I now have the regex running doing exactly what I want without compromizing the original functionality since yesterday.
    Not only /.well-known/acme-challange/ and other folders, depending on the rewrite type, are excluded from rewrites but /.well-known/security.txt as well.
    Tested all I could and everything seems to do what I want.
     
    till likes this.

Share This Page