How-To: VirtualHost

Hi to all, small manual for making your own VirtualHost :

  1. Create custom templates:

    mkdir -p /etc/e-smith/templates-custom/etc/httpd/conf/httpd.conf
    touch /etc/e-smith/templates-custom/etc/httpd/conf/httpd.conf/80VirtualHost

  2. Edit your VirtualHost :

    vi /etc/e-smith/templates-custom/etc/httpd/conf/httpd.conf/80VirtualHost

    My Vhost

    <VirtualHost 0.0.0.0:443>
    ServerAdmin admi@example.com
    ServerName admin.example.com
    DocumentRoot /usr/share/roundcubemail
    <Directory /usr/share/roundcubemail>
    #Options Indexes FollowSymLinks MultiViews
    AllowOverride None
    Order allow,deny
    allow from all

    ErrorLog /var/log/httpd/example.com-error.log

         LogLevel warn
    
         SSLEngine on
    
         SSLCertificateFile /etc/ssl/example.com.crt
         SSLCertificateKeyFile /etc/ssl/example.com.key
         #SSLCertificateChainFile /etc/ssl/sub.class1.server.ca.pem
         #SSLOpenSSLConfCmd DHParameters /etc/ssl/dhparams.pem
         SSLStrictSNIVHostCheck Off
         SSLCACertificateFile /etc/ssl/sub.class1.server.ca.pem
         <FilesMatch "\.(cgi|shtml|phtml|php)$">
                 SSLOptions +StdEnvVars
         </FilesMatch>
    
  1. Put your custom SSL in /etc/ssl if you make HTTPS Virtualhost
a) As for OWNCLOUD you should add Trusted domain :

    config setprop owncloud TrustedDomains server.domain.com
    signal-event nethserver-owncloud-update 
  1. Run signal event :

    signal-event nethserver-httpd-update

  2. Have a good day :smile:

3 Likes

Hi @nas why not just putting a .conf file in /etc/httpd/conf.d? I think the templates-custom is not needed here!

1 Like

the .conf file in conf.d dir approach is good only when it doesn’t have any (possible) value that can change in a server reconfiguration (IP, name, $whatever)

template is there just to have a “config and forget” approach, without dealing with future conf changes that could break your services…

let’s say I have 20 webapps running, with 20 conf files: changing (for example) my IP (I repeat, this is an example) will need 20 checks, with template approach, 0…

it has been so for almost 20 years and it just works :slight_smile:

I agree dynamic templates are useful, but @nas example does not have any dynamic part. This is a typical real world case, where the only “parameter” is the virtual host name. I still think a template is not useful for one Apache virtualhost.

1 Like

@nas you should write the howto on wiki.nethserver.org

1 Like

As for dynamic template we need to add option to the owncloud and roundcube. And all ssl path so it is rather complicated. We have installed SIWAPP so vitrualhost is much differ than owncloud one.I wrote only way to make your own virtualhost, because i’v spent some time for investigation.

we should add this to the UI

1 Like

Hi Bogdan in which way? There are so many options it is very complicated and it is huge piece of work :frowning:

Hi Artem,
I think that having a UI to add Vhosts and specify parameters directly from the UI should be useful.
@davidep @stephdl @Nas @filippo_carletti @dz00te @filippo_carletti @alefattorini @All, do you want to chip in and create something that Zentyal had in the webserver UI panel ?

2 Likes

I would be interested by a list of all features needed here and provided by zentyal…apache is my hobby.

For example i looked today to provide the webdav support…none line of code is written but i did some searchs on the topic. i feel that i don’t need to patch a core rpm.

But for the virtualhosts its needed to do it…so before to waste time to code…a pre agreement is wanted :slight_smile:

1 Like

I agree Stephane,
A list of features is needed. This will also make easier to create an algorithm and see what we need to do.

Reverse proxy?

(It’s useful when you have only one Public IP on RED and you have at least 2 servers on ORANGE that use in the same time http or https (E-mail Server with Webmail and Web Hosting, …). It’s nice to do this from UI). - From here: My wishes list (or Letter to Santa)

Merry Christmas to all!

25 posts were split to a new topic: Scared to try to use NS and vhosts

these are some clues -> http://dev.nethserver.org/projects/nethserver/wiki/Nethserver-httpd

2 Likes

A post was split to a new topic: Proposal for ns7 VirtualHost page

Hi,

I get an Error during creating a Virtual Host

Errormessage:

Stopping httpd: [ OK ]
Starting httpd: Syntax error on line 360 of /etc/httpd/conf/httpd.conf:
order takes one argument, ‘allow,deny’, ‘deny,allow’, or ‘mutual-failure’

My Host:

> <VirtualHost *:80>
>         ServerAdmin hostmaster@xxxxxxxxxx.de
>         ServerName www.xxxxxxxxxx.de
>         DocumentRoot /home/nicky/pki2017/web
>         <Directory /home/nicky/pki2017/web>
>                 #Options Indexes FollowSymLinks MultiViews
>                 AllowOverride None
>                 Order allow,deny               **<------ Error in this Line**
>                 allow from all
>         </Directory>
>         ErrorLog /home/nicky/pki2017/web/xxxxxx.de-error.log

>         LogLevel warn


> </VirtualHost>

After change Line 12 to Order allow

Starting httpd: Syntax error on line 12 of /etc/httpd/conf.d/webhost_xxxxxx.conf:
unknown order

I need the host only to distribute files (Certificates etc…)
Please help me.

Thanks

Nicky

1 Like

Check for unwanted extra spaces.
By the way, there’s a virtualhosts module.

1 Like