Results 1 to 7 of 7

Thread: Apache - map a port to a specific directory

  1. #1
    Join Date
    Dec 2008
    Location
    UK
    Beans
    399
    Distro
    Ubuntu 11.10 Oneiric Ocelot

    Question Apache - map a port to a specific directory

    I have a server set up (running 12.04 server) which runs SugarCRM CE, essentially for internal use at work. However I want to enable data from an external website (outside the lan) to be added to the SugarCRM database.

    What I was thinking of doing is opening a port on our internet router to allow access from the external webserver to the internal server. But I obviously don't particularly want the server visible to all and sundry, consequently I want to know if it possible to redirect traffic on the open port to one specific folder within the SugarCRM installation.

    i.e. www.example.com:100 goes to /var/www/sugar/folderX

    Opening the port is easy enough but despite a good search on the internet I haven't managed to find a clear method to implement this in apache. What information I have found is contradictory with suggestions involving virtual hosts and reverse proxys and both stating the other option won't work.

    Can anyone help to point me in the right direction please.

  2. #2
    Join Date
    Oct 2009
    Beans
    Hidden!
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: Apache - map a port to a specific directory

    My first thought was using virtual hosts, but I don't know if that will accomplish what you want.

    How is the data you want added from an external source going to get imported into SugarCRM?
    Come to #ubuntuforums! We have cookies! | Basic Ubuntu Security Guide

    Tomorrow's an illusion and yesterday's a dream, today is a solution...

  3. #3
    Join Date
    Dec 2008
    Location
    UK
    Beans
    399
    Distro
    Ubuntu 11.10 Oneiric Ocelot

    Re: Apache - map a port to a specific directory

    Virtual hosts is one option I came across, but then another site said this wouldn't work.

    I believe data is added to Sugar via php/soap (need to read up on this), I'm waiting to find out from the software supplier exactly how it works and I need to root around in the sugar installation to find out what is in certain folders.

  4. #4
    Join Date
    Nov 2008
    Location
    Metro Boston
    Beans
    8,764
    Distro
    Kubuntu 14.04 Trusty Tahr

    Re: Apache - map a port to a specific directory

    Virtual hosts would definitely work. You'll need to have Apache listen on another port beside 80, then bind a virtual host to the address and port like this:

    Code:
    Listen 8080
    <VirtualHost *:8080>
         ServerName backdoor.example.com
         DocumentRoot /var/www/sugar/folderX
    
         <Directory /var/www/sugar/folderX>
              Options Indexes FollowSymLinks MultiViews
              AllowOverride None
              Order allow,deny
              allow from all
         </Directory>
    </VirtualHost>
    You'll probably want some other controls over the vhost like password protection. Put these directives in a file in /etc/apache2/sites-available and create a symlink to the file in /etc/apache2/sites-enabled (or use a2ensite). Then restart apache with "sudo service apache2 restart".

    Have your router forward an external port (choose one over 1023) back to the server's port 8080 or whatever port you choose for the virtual host.
    Last edited by SeijiSensei; May 19th, 2012 at 04:02 PM.

  5. #5
    Join Date
    Dec 2010
    Beans
    570
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: Apache - map a port to a specific directory

    If the files you are trying to share in that directory are already created and the external client is just retrieving them via HTTP(S) then a virtual host could work.

    If the files that the client will be accessing require active content like PHP to retrieve them then the setup may be a bit more complicated and my not work within the application you are using.

  6. #6
    Join Date
    Sep 2006
    Beans
    7,309
    Distro
    Lubuntu Development Release

    Port-based virtual hosts

    SeijiSensei's example should do it for you. If you're looking for other examples, the term to look for is "port-based virtual host"

  7. #7
    Join Date
    Dec 2008
    Location
    UK
    Beans
    399
    Distro
    Ubuntu 11.10 Oneiric Ocelot

    Re: Port-based virtual hosts

    Thanks everybody, I'll have a go and see what happens.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •