Get the most out of your Centmin Mod LEMP stack
Become a Member

Multiple Applications - Single domain

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

  1. Colin

    Colin Premium Member Premium Member

    108
    32
    28
    Oct 7, 2015
    Sheffield UK
    Ratings:
    +80
    Local Time:
    8:03 AM
    1.11.#
    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

    28,943
    6,570
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +9,751
    Local Time:
    5:03 PM
    Nginx 1.13.x
    MariaDB 5.5
    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 :)
     
    • Agree Agree x 1
  3. Colin

    Colin Premium Member Premium Member

    108
    32
    28
    Oct 7, 2015
    Sheffield UK
    Ratings:
    +80
    Local Time:
    8:03 AM
    1.11.#
    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.
     
    • Informative Informative x 1
  4. eva2000

    eva2000 Administrator Staff Member

    28,943
    6,570
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +9,751
    Local Time:
    5:03 PM
    Nginx 1.13.x
    MariaDB 5.5
    yeah trial and error testing is probably best way to see what works or not :)