SUSE Conversations


How to Run NetStorage Within a Virtual Host in SLES



By: coolguys

August 11, 2006 12:00 am

Reads:232

Comments:0

Rating:0

Problem:

Running NetStorage inside a virtual host.

Solution:

How to run NetStorage within a virtual host in SLES

What is needed to accomplish the following steps:

  1. A server with Novell SLES installed and properly configured and updated.
  2. Working copy of Apache and Tomcat with NetStorage installed and tested.
  3. A DNS “cname” for NetStorage, and point it to the SLES server you are going to use. (note you can test this using the hosts file within your OS if you don’t want to add the DNS entry till you’re finished and tested.)

To use the hosts file:

When you open the hosts file there should be a line telling you how to use the file, most systems have use the following:

  • {hostname you want to use}{white space}{ip of your server}[whitespace][alias short name]
    *note the [] are optional
  • You can find the hosts file at the following locations for the listed operating systems:

    Linux/Unix/Mac OSX: /etc/hosts

    Windows XP/2000: %sysdir%\drivers\etc\hosts (%sysdir% is a variable that points to your system32 folder location inside the windows installation folder)
  • SUSE: (is Linux see above)

Tips for success:

  • Don’t use Yast (Yast2 included) to configure Apache. It can cause problems because it changes settings within some conf files just by clicking the “Finish” button in the “HTTP Server” module.

    Note you have been warned. Yast can cause serious issues and make you to reinstall apache; at least cause a time-consuming manual fix of errors. It won’t break things all the time, but it is best to avoid the risk.

  • The files within /etc/apache2/vhost.d/ directory are loaded alphabetically. For example vhost-mydomain.conf will load before vhost-notadomain.conf. Easy way around this is append a number to the front of each file within the vhost.d directory. So in the above example you wish notadomain.conf to load first use the following.

    1_vhost-notadomain.conf 2_vhost-mydomain.conf or something to that effect. Apache will still look for a “_default_” server before heading to the first loaded virtual host file.

The how to:

Connect to the server remotely or login the console as root then open /etc/opt/novell/netstorage/NetStorage.conf with your choice of text editor. Copy the contents; we will need these settings with some slight modifications in order to get Tomcat to mount NetStorage directly within the virtual host.

File: “/etc/opt/novell/netstorage/netstorage.conf”

# The following lines makes apache aware of the location of the /NetStorage context
Alias /NetStorage "/opt/novell/NetStorage/webapp"
Alias /NetStorage "/opt/novell/NetStorage/webapp"
<Directory "/opt/novell/NetStorage/webapp">
    Options +MultiViews
    AllowOverride None
        Order deny,allow
    Allow from all
</Directory>
 
# The following line mounts all JSP files and the /servlet/ uri to tomcat
JkMount /NetStorage/servlet/* ajp13
JkMount /NetStorage/*.jsp ajp13
 
# The following section makes /NetStorage/servlet a protected resource.
<Location "/NetStorage/servlet">
    AllowOverride AuthConfig
    AuthType Novell
    AuthName "AuthXTier"
    require valid-user
    Order deny,allow
    Allow from all
</Location>  
# The following line prohibits users from directly accessing WEB-INF
<Location "/NetStorage/WEB-INF/">
    AllowOverride None
    deny from all
</Location>
 
# Use Directory too. On Windows, Location doesn't work unless case matches
<Directory "/opt/novell/NetStorage/webapp/WEB-INF/">
    AllowOverride None
    deny from all
</Directory>
 
# The following line prohibits users from directly accessing META-INF
<Location "/NetStorage/META-INF/">
    AllowOverride None
    deny from all
</Location>
 
# Use Directory too. On Windows, Location doesn't work unless case matches
<Directory "/opt/novell/NetStorage/webapp/META-INF/">
    AllowOverride None
    deny from all
</Directory>
 
 
AddLanguage zh-tw .zh-tw
AddLanguage zh-cn .zh-cn
AddLanguage sk .sk
AddLanguage hu .hu

Now create a new file inside the directory /etc/apache2/vhost.d/. For readability sake I named the file “vhost-netstorage.conf”. To help others know what the file is doing.

Add the standard virtual host lines to the new file and paste the info above into the file.

Now we need to point our virtual host to NetStorage’s directory. The location is “/opt/novell/netstorage/webapp/” and paste the contents of /etc/opt/novell/netstorage/netstorage.conf then remove the aliases at the top of the file; these will not be needed for the virtual host.

Now that our virtual host points to the correct path we need to change the point where Tomcat will mount the NetStorage and do a quick edit and check of the location/directory permissions. Since we wish to remove the requirement of /NetStorage/ we must remove the references to it and tell Tomcat to mount at the same time the virtual host is hit. Other articles have suggested a page to redirect you to /NetStorage/ but we will tell Tomcat to mount NetStorage directly your sub.domain.ext!

Then add or change the ServerName to the cname you wish netstorage to be allocated to, also give the server’s your admin email.

There are a few places that need to be changed. The edits are in bold them so it is easier to see. The virtual host file would be something similar to the following. Italics are options which aren’t required, but I wanted the options within the virtual host for looks and speed.

File: “/etc/apache2/vhost.d/vhost-netstorage.conf”

<VirtualHost *:80>
 UseCanonicalName On
 HostnameLookups Off

 DocumentRoot /opt/novell/NetStorage/webapp/
 ServerName sub.doamin.ext
 ServerAdmin user@doamin.ext

 ServerSignature On
 <Directory "/opt/novell/NetStorage/webapp">
  Options +MultiViews
  AllowOverride None
  Order deny,allow
  Allow from all
 </Directory>
 JkMount /servlet/* ajp13
 JkMount /*.jsp ajp13
 <Location "/servlet">

  AllowOverride AuthConfig
  AuthType Novell
  AuthName "AuthXTier"
  require valid-user
  Order deny,allow
  Allow from all
 </Location>
 <Location "/WEB-INF/">
    AllowOverride None
    deny from all
 </Location>
 <Directory "/opt/novell/NetStorage/webapp/WEB-INF/">
    AllowOverride None
    deny from all
 </Directory>
 <Location "/META-INF/">
    AllowOverride None
    deny from all
 </Location>
 <Directory "/opt/novell/NetStorage/webapp/META-INF/">
    AllowOverride None
    deny from all
 </Directory>
 AddLanguage zh-tw .zh-tw
 AddLanguage zh-cn .zh-cn
 AddLanguage sk .sk
 AddLanguage hu .hu
 <IfDefine SSL>
  SSLEngine off
 </IfDefine>

</VirtualHost>

Because default-server.conf is holding all the settings required to load the Novell welcome page and is global to all virtual hosts. We need to create default server for it to load though. Create another file something along the lines of vhost-default.conf and add a blank _default_:80 virtual host for port 80. Something similar to the following:

File: “/etc/apache2/vhost.d/vhost-default.conf”

<VirtualHost _default_:80>
</VirtualHost>

When an unknown virtual host or hostname is hit; Apache will now display Novell’s default welcome page, just like it did before the virtual hosting was enabled.

Now it is time to test the configuration and see if apache likes / noticed our changes. Go to the Terminal and enter the following command:

# /etc/init.d/apache2 configtest -S

This will test the configuration files for syntax errors (should be none) and then display a list of default servers and virtual hosts. Hopefully you will get a message similar to the following:

Example output of “/etc/init.d/apache2 configtest -S” command

# /etc/init.d/apache2 configtest -S
VirtualHost configuration:
wildcard NameVirtualHosts and _default_ servers:
_default_:443          servername.sub.domain.ext (/etc/apache2/vhosts.d/vhost-ssl.conf:28)
*:80                   is a NameVirtualHost
         default server namevhost servername.sub.domain.ext (/etc/apache2/vhosts.d/vhost-default.conf:1)
         port 80 namevhost servername.sub.domain.ext (/etc/apache2/vhosts.d/vhost-default.conf:1)
         port 80 namevhost sub.domain.ext (/etc/apache2/vhosts.d/vhost-myfiles.conf:1)
Syntax OK

If you received a similar message to the one above you have successfully setup your SLES server to run NetStorage within a virtual host!

Notes:

If you wish for NetStorage to only load via this virtual host you can remove the NetStorage symbolic link per the iManager article located here: http://wiki.novell.com/index.php/IManager_Virtual_Host

Environment:

I used a SLES9 server w/ standard Apache2 setup, and SUSE10.1 for the test client PC. The server’s configuration files were edited via Fish over SSH using Kate text editor.

VN:F [1.9.22_1171]
Rating: 0.0/5 (0 votes cast)

Categories: Uncategorized

Disclaimer: As with everything else at SUSE Conversations, this content is definitely not supported by SUSE (so don't even think of calling Support if you try something and it blows up).  It was contributed by a community member and is published "as is." It seems to have worked for at least one person, and might work for you. But please be sure to test, test, test before you do anything drastic with it.

Comment

RSS