New user's registration have been closed due to high spamming and low trafic on this forum. Please contact forum admins directly if you need an account. Thanks !

Apache configuration questions

Got problems with Bubba? Then this forum is for you.
Locked
msx
Posts: 106
Joined: 13 Jan 2007, 06:03
Location: Venice
Contact:

Apache configuration questions

Post by msx »

Hi, i have a couple of questions about apache configuration. Not really bubba related, but maybe someone can help. I've never configured apache before :)

I'm running a couple of services on the bubba that have http interfaces. I'd like to reach them from the outside, but i'm firewalled at work and i can only exit on port 143 and 80 (https and http).

I have dyndns with subdomains, so i'd like to have something like this:

https://my.dyndns.com -> main bubba sites
https://app1.my.dyndns.com -> application 1 web interface
https://app2.my.dyndns.com -> application 2 web interface

So apache2 should act like a "proxy", forwarding requests to my applications and showing the results.
Is it possible? any hint on how to do this?

Another question: i was wondering about SSL certificates.. are they identical for all bubbas? (ie, do you install the os with an image?) it is difficould to replace them with new ones ?
tor
Posts: 703
Joined: 06 Dec 2006, 12:24
Contact:

Post by tor »

Hi msx,

Regarding the subdomains,

In this case you should use virtual hosts in apache.

For each "subdomain" you should create a file in

/etc/apache2/sites-available

The file, lets call it app1, /etc/apache2/sites-available/app1. Should look something like this (Minimal example):

Code: Select all

<VirtualHost *:80>
        ServerName app1.my.dyndns.com 
        DocumentRoot /var/www/app1
        ServerAdmin webmaster@my.dyndns.com

        ErrorLog /var/log/apache2/app1_error.log
        LogLevel warn
        CustomLog /var/log/apache2/app1.log combined
        ServerSignature On
</VirtualHost>


<VirtualHost *:443>
        
        ServerName app1.my.dyndns.com
        DocumentRoot /var/www/cool
        ServerAdmin webmaster@my.dyndns.com

        SSLEngine on
        SSLCertificateFile      /etc/apache2/my_cert.pem
        SSLCertificateKeyFile   /etc/apache2/my_privkey.pem

        ErrorLog /var/log/apache2/app1_error.log
        LogLevel warn
        CustomLog /var/log/apache2/app1.log combined
        ServerSignature On
</VirtualHost>
Where DocumentRoot points to the web root directory or web application install.

Make sure that DynDNS is updated with pointers for app1.my.dyndns.com.

Enable the site on bubba

Code: Select all

a2ensite app1
Reload configurations in apache

Code: Select all

/etc/init.d/apache2 reload
Now apache should show your web-app when you direct your web browser to app1.my.dyndns.com.

Regarding SSL certificates.

These are indeed the same on all Bubbas, since as you correctly guess have an filesystem image for installation.

If you want to change them. Pointed out above with SSLCertificateFile and SSLCertificateKeyFile in the config above. You can do as follow.

Code: Select all

openssl req -new -x509 -nodes -out my_cert.pem -keyout my_privkey.pem
And answer the questions Fx

If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [AU]:SE
State or Province Name (full name) [Some-State]:My State
Locality Name (eg, city) []:.
Organization Name (eg, company) [Internet Widgits Pty Ltd]:My Company
Organizational Unit Name (eg, section) []:Web
Common Name (eg, YOUR name) []:app1.my.dyndns.com
Email Address []:info@app1.my.dyndns.com

This will generate the two files:

my_cert.pem - the certificate
my_privkey.pem - the private key used

The path to these files should match in above config.

An important note here. You can only have one certificate usable at a given time (Per IP number and port at least). So this must be the same as used in the main config, /etc/apache2/sites-available/bubba, if not bubbas original certificate will be used.

I hope this give some hints on how to do this.

/Tor
Co-founder OpenProducts and Ex Excito Developer
msx
Posts: 106
Joined: 13 Jan 2007, 06:03
Location: Venice
Contact:

Post by msx »

Thank you, very useful informations.
But i miss one step: my applications have their own internal web server, they're not just php applications (for example mldonkey or webmin).

Is it possible to have them proxied by apache in some way?
tor
Posts: 703
Joined: 06 Dec 2006, 12:24
Contact:

Post by tor »

Ok, in this case i think you want to run what is called a reverse proxy. More info can be found here: http://httpd.apache.org/docs/2.0/mod/mod_proxy.html

/Tor
Co-founder OpenProducts and Ex Excito Developer
msx
Posts: 106
Joined: 13 Jan 2007, 06:03
Location: Venice
Contact:

Post by msx »

great, i'll take a look, thank you
sgadd
Posts: 4
Joined: 10 Feb 2007, 18:49
Location: Lund, Sweden

diffrent target when using IP# and domain.se

Post by sgadd »

Hi

I host a domain on my bubba but would like to see diffrent webpages depending on if i use the IP of my bubba or the domain name when acessing it from a web browser.

All virtualHost exaples I can find handles multiple domains only.

Anyone that has an solution for this?
Locked