Discover Centmin Mod today
Register Now

Multiple Applications - Single domain

Discussion in 'Other Web Apps usage' started by Colin, May 22, 2017.

  1. Colin

    Colin Premium Member Premium Member

    192
    59
    28
    Oct 7, 2015
    Sheffield UK
    Ratings:
    +154
    Local Time:
    5:52 PM
    1.19.#
    MariaDB 10.1.#
    HI,

    I know this isn't out of the box centminmod supported!

    The scenario is a single website that has evolved the example.tld has a home index page and content, and a 'forums' application.

    / -> index.html
    /about -> /about/index.html
    /forums -> php forums app

    To this, the owners want to redo the index with some new/updated static content and then add new dynamic functionality, via new external applications, so not / or /forums but say /app1 /app2.

    Now clearly a subdomain would work here: app1.example.tld app2.example.tld #done.

    But I got to thinking about that /forums and statics at /index.html. Currently, the index updates are done over sftp upload, as to, are the forum ones. In the new CI world, static generators can rsync or git hook & push etc to deploy. I'd be happier if the /index.html & assets and /forums were not in the same public/ folder.
    So I'd like to see:
    1. /home/nginx/domains/www.example.tld/public/index.html
    2. /home/nginx/domains/www.example.tld/forums/index.php

    Then use nginx to root /forums to the #2 folder. This can be done with the root/alias directive in a location block.

    Before I run off waving, has anyone done similar and had issues?


    If going to a separate folder, I'm some of the way, but I'm not totally happy. I'd still prefer to have separate concerns, separated. So separate logs/backups/config/logins/perms. But forums.example.tld isn't going to work for 99% non-technical reasons.
    My initial thinking got me to internally I could proxy the 'subdomain'. Add an external block to prevent 'leaks'.

    This second way seems neater; barring the internal proxy, and slightly better for ensuring no accidental overwrites or deletes made during the upload of index files. ( I am pushing to automate it all )

    Any thoughts or alternatives?

    I was thinking about haproxy as it has a subdirectory -> backend way. But that's even further off the centminmod reservation.
    Code:
    acl has_forums_uri path_beg /forums
    use_backend forum_servers if has_forums_uri
    default_backend home_servers
     
  2. eva2000

    eva2000 Administrator Staff Member

    54,884
    12,240
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,811
    Local Time:
    3:52 AM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    Well if that's a concern, then separating is best way. It's how centminmod.com and community.centminmod.com and wordpress7.centminmod.com and piwik analytics servers sites are setup. Separate sites and even separate servers. Less headaches, more secure and allows me to easily scale or migrate a specific site segment to new servers if that segment's traffic and popularity grows. I don't have to move everything just if one segment requires more server resources to meet growth needs.

    Understandably, not all sites can be organised in such a way. So then you'd have to forgo some separation to muddle the waters so to speak and use nginx root path aliases and separate custom php.conf includes as they also take their document root from the root path directive defined. Also can define specific access and error logs for location block matches to filter own access and error log entries. It's sort of what I did for setting up separate log files to log HTTPS/TLS protocol statistics.

    For uploads by ftp/sftp, most FTP clients can setup profiles to define initial starting local and remote directories, just have separate FTP profiles for the static site and forum starting local and remote directories. Easy and what I do as a shortcut for specific FTP related tasks I need to do i.e. if download backup files, have a specific FTP backup profile set to the starting local backup folder and remote backup folder, so connecting via that specific FTP backup profile lands me right into the specific local and remote backup folders out of the gate :)
     
  3. Colin

    Colin Premium Member Premium Member

    192
    59
    28
    Oct 7, 2015
    Sheffield UK
    Ratings:
    +154
    Local Time:
    5:52 PM
    1.19.#
    MariaDB 10.1.#
    I totally concur the subdomain route is preferable. There is going to be a mix of technology and platforms. No budget to pay for server mgmt for lots of nodes, so PAAS it is.

    The challenge is two fold, one I want to do away with FTP and an initial remote folder isn't enough of a defence. Then automation wants nice clean spaces. The only non-automated bit will be the forums app.

    Middleman can deploy via Rsync, it can keep the old assets ( not a bad idea technically ) but if it gets to delete, then bye bye sub-folder forums. #cry. Deploy via git pushes equally will blow away the non-repository subfolders without some post deploy dancing. Possible, not pretty, but possible.

    So I think I'll have to pursue separated internal sites. I think, on paper at least, the only non-standard is internally proxying to ip/port.

    So www.example.tld is the original site, set up as per normal, can run letsencrypt etc. Within that is a location block for /forums. This will proxy off to forums.internal.example.tld or #.#.#.#:#### which is running as a separate vhost setup.
    I'll have a play, on paper it should be ok... hah.
     
  4. eva2000

    eva2000 Administrator Staff Member

    54,884
    12,240
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,811
    Local Time:
    3:52 AM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    yeah trial and error testing is probably best way to see what works or not :)