Where do I update the configuration for virtualhosts (redirects)?

NethServer Version: 7.2009
Module: Web Server

So I need to know where to add permanent apache redirects to common URL’s, we’re coming from a cPanel based system to NethServer so some users are still using /webmail on the root domain to get to SOGo and we’d like to keep that a thing.

Right now I have it set up as a 301 redirect using HTACCESS in that main sites root, but we’d like the redirect to be done on a httpd level, as htaccess could be modified via ftp and could cause additional problems. Where do we add the redirect configuration for that URL, because it appears that when making changes to the virtualhost through the GUI, the virtualhosts.conf file is automatically updated, and erases any changes.

We want this done only for the one domain. Is there a way to do it so that in the template for this domain it will automatically just keep those in there? Anyone have experience with this on NethServer?

hum AFAIK SOGo is hardcoded, I am not sure you can change it like this, at least it works well.

What apache directive do you want to add ?

https://docs.nethserver.org/projects/nethserver-devel/en/latest/templates.html

You have to write a custom-template

It’s not SOGo I’m looking to change. it’s one of the Virtual Hosts under the web server module. I need to add some redirects that redirect to things like our AutoConfig setup, webmail, and a few events we normally hold.

For example, I’m trying to hard code domain.com/webmail, domain.com/email and domain.com/mail to redirect to mail.domain.com. Basically 301 redirects.

reverse proxy of the httpd application in cockpit ?

Reverse proxy creates the redirects on all configured domains doesn’t it? We only want the one main domain name, which is already listed on the virtual hosts for the web server module.

indeed true for all domains of NS

SSLProxyEngine on
# ProxyPass: webmail
# Description: 
ProxyPass       /webmail        https://mail.domain.com
ProxyPassReverse        /webmail        https://mail.domain.com
<Location /webmail>
    SSLRequireSSL
</Location>

Yes but as soon as I make that change in the .conf file, it will erase it when any change is made via the GUI won’t it? That’s what I’m trying to avoid.

NS read vars from e-smith database and write configuration files with e-smith template. You have to write a custom template if you want to avoid this or drop your apache configuration in another filr.You should read the documentation I gave

I did it with the gui of proxypass…not sure we understand each others

That was regarding the configuration and directly changing the file, not using proxypass in the GUI. I tried Reverse Proxy in the GUI and all it’s doing is adding “SOGO” to the URL. My assumption is that it is getting that from mail.domain.com, as that is where SOGo is located, which is what I’m trying to redirect domain.com/webmail to.

I don’t believe that reverse proxy is what I’m looking for, as I’m just looking for a simple URL redirect that is hardcoded into the configuration. The Web Server module needs a place for each virtual host where you can add custom configuration for each host. I think that would solve my issue.

Please output the apache redirection code you want to do

Something similar to this:

Redirect /webmail https://mail.domain.com/
Redirect /mail https://mail.domain.com/
Redirect /email https://mail.domain.com/
Redirect /event https://www.domain2.com/event-title

This is achievable using a standard apache installation (I’ve tested it with a few other servers that run apache and CentOS and they work flawlessly.

You can find it referenced here:

this an example of redirection done for roundcubemail

I still continue to think that the proxypass example I gave is the easy solution.

Here’s an example of the same thing I’m trying to accomplish but pulled from a non-Nethserver server. I have this setup with a separate domain name, setup pointing somewhere completely different.

<virtualhost *:80>
ServerName domain.com
ServerAlias  www.domain.com
ServerAdmin webmaster@domain.com
DocumentRoot "/home/domain/www/domain.com/"
ErrorLog "/home/domain/logs/domain.com-error.log"
CustomLog "/home/domain/logs/domain.com-access.log" combined_with_forwarded_for
CustomLog "/home/domain/logs/domain.com-bandwidth.log" common

## Custom Redirects
Redirect /webmail https://mail.domain.com/

<Directory "/home/domain/www/domain.com">
Options +FollowSymLinks -Indexes
AllowOverride All
Require all granted
</Directory>
</virtualhost>

Using the example above, I need a way to add the Apache directive REDIRECT to the VHOST for domain.com, and have that stay there regardless of GUI modification.

Additionally, I’ve done more testing, the Reverse Proxy doesn’t redirect, it simply creates a rewrite to the URL presented at that URL, which is not what I’m attempting to accomplish. I only want this to be done on the one Apache VHOST, not globally for any subdomain or root domain we configure.

Well you have to create a custom template with a condition to be enabled by the name of the vhosts. You must know esmith template engine and some basic perl condition

The easier is to drop your apache configuration directly in /etc/httpd/conf.d/

What you are requesting is not implemented inside the vhost UI, if you want so it is a feature request you need to do

1 Like