I currently have a small team (2 people) working on project one of my site:
http://www.example.com/one/
I want to be able to assign more teams to future projects, such as team 2 for project two:
http://www.example.com/two/
It's sort of like how big corporate sites such as Microsoft.com is being built and managed, different sub-directory (projects) for different teams. Each of the teams has the privileges to run and manage their own project as a sub-directory of the root domain.
After some searches, I came about the mod_proxy module of Apache. It seems a perfect fit. However as I currently only has one team, or there might be other projects for more teams but the overall traffic is not so much as to need a whole new other server, my question is, how to relay the requests to another directory in the same server?
I know I can just set up different directories under different users but I want to be easily scaling out when the traffic actually takes off so I'd prefer using mod_proxy for this because I can actually add more servers when I need to.
ProxyRequests Off
ProxyPass /foo http://internal/bar
ProxyPassReverse /foo http://internal/bar
Wherein internal/bar is located at /home/team1/public_html
Is this possible? How to make this happen?
Or as per my need, is there any way that's fundamentally better than the mod_proxy approach?
There are a few ways to do this but you probably don't have to use reverse proxy unless your keen on having the projects on different ports/host names and don't want the user to know. Other wise just use Alias
If using mod_proxy you would want to put the reverseproxy directives in a www.example.com vhost entry, you could also specify a document root for it. Then setup more vhosts for each of your projects, e.g. one.example.com. Each vhost can have a different DocumentRoot specified. Note you could accomplish something similar to reverseproxy via Redirect permanent however this would require a dns being setup for the subdomains. With your mod_proxy solution you can just add the subdomains to the hosts file.
Use one of the methods mentioned here: https://httpd.apache.org/docs/1.3/urlmapping.html
Alias directive, ScriptAliasMatch, User Directories with AliasMatch
Related
In tutorials, I have seen prestashop installed in at least three different DocumentRoot's:
/var/www/html/
/var/www/html/prestashop/
/var/www/html/prestashop/public_html
Is there any logical reason to prefer one location over the others? In my case, there is an Apache server and I will have two different websites (two domains).
/var/www/html is the default directory for apache default config.
Prestashop is meant to be used at the web root, so no matter what you choose you must adapt the apache configuration to match the directory where prestashop actually is.
That being said, you should go for /var/www/yourdomain.com or /opt/website/yourdomain.com (I think it fits more the File Hierarchy Standard).
People sometimes use /var/www/domain.com/public_html so they can put some private content in /var/www/domain.com that can be used by their website but is not facing the web.
Do use nested subdirectories if you don't have a reason for it. Go for the most straightforward way.
I've just reset my Ubuntu 14.04 LAMP server hosted with digital ocean. Could someone tell me the 'proper' way to do server configuration. My goal is to do everything as clean as possible (and hopefully well structured).
I intend on using the server mainly for programming and data analytics, however I do plan on hosting my website in /var/www/html. I also plan on using letsencrypt/certbot to get an easy SSL. With this in mind, these are the main goals I would like to accomplish:
1) Redirect the website to ALWAYS be served through https AND www.
2) Enable HSTS for the entire website.
3) Enable clean url's (remove .php extensions and what not).
Since I would like all of these properties to be used across the entire website, should the configuration be done inside of the /etc/apache2/ folder? Or should it be done inside of .htaccess?
And if it should be done inside of apache2 configuration, which file should I add it to? And finally, how exactly should it be added? (for example vhost 80/443, inside of a mod_something section, etc).
Thank you in advance, I would appreciate and consider any advice about Apache and htaccess!
We have a SaaS product and we give websites for customers. The customers can request to have their own domain pointed to their website. At the moment we use httpd.conf file to add a VirtualHost entry pointing to the same document directory. Afterwards the database will load the website by matching the URL. We realized there are couple of problems with this approach and this is not scalable at all.
If there is a mistake in httpd.conf file their is potential the whole product might not work. This has actually happen. Also, we use WHM and cPanel, so when we add a mod or does a tweak in the live server, the entire httpd.conf gets rewritten having us to replace/add existing virtual host entries to the file.
Strangely in our QA server, i did not have to add any virtualhost entries and as soon as a new domain is pointed, the website is picked up from the database. I realized the virtualhost entries were needed in the live server only. Both have Apache 2.4 CentOS installed. Is there a reason behind this? Im sure this has something to do with a configuration change.
Hope someone can point me in the right direction where i can achieve the same in our live server environment.
Cheers!
In Apache VirtualHosts add versatility but you are not forced to create any.
Apache will listen to the interfaces you tell it to (with the Listen directive) and when receiving requests if you haven't defined any virtualhosts the default server config will answer all requests.
The moment you add a virtualhost, that will be used to answer all requests, and if you add more virtualhosts the servername in them is examined to determine where to deliver requests depending on the incoming host header.
There really isn't anything more to it really.
let's suppose we have shopify.com,a platform where everybody can create his e-shop and provide it under his domain,the user can add his domain in other words.
When somebody ads a domain,what's actually happening under the hood?
As far as i know,in apache2 a new VirtualHost is created for each new domain,pointing to the user's folder. But is this the best and most efficient solution to this?
I'm asking for curiosity reasons mainly and also i'd like how those systems work (like shopify.com or webs.com,where every user adds a domain)
Thank you in advance!!
You have a few options that I know of, mostly depending on whether traffic goes to the same ip or not.
When setting up DNS entries you can specify wildcard for subdomains. *.example.com which makes it so that any request for any subdomain that isn't match by another DNS record goes to example.com.
So, having:
*.example.com <ip A>
blog.example.com <ip B>
Would make blog.example.com go to < ip B> and example.com and all other subdomains go to < ip A>.
This means you could have the possibility of giving each new subdomain go to its own ip (very unlikely). You can also catch them all at the same ip and handle it there.
As you mentioned, you could add a new virtual host for each new sub domain created. However, that's kind of a heavy solution, and I think it would generally involve restarting your webserver program to reload the new configuration. Instead, you can use something like rewrites to achieve something similar to the virtual host.
Having a rewrite rule that does <subdomain>.example.com/<resource> => example.com/<subdomain>/<resource> would mean all that would be necessary is creating a new folder in the root of your served directories containing the user's content. No change to configuration. Also, I'm not sure if you're familiar with rewrites, but, they're invisible to the browser/user, so the user still sees <subdomain>.example.com/<resource> even though they're being served content from example.com/<subdomain/<resource>.
This isn't a definitive list of the possibilities, simply a couple possibilities. Any large or scalable solution is probably going to involve many layers of indirection allowing for more complex DNS directing, load balancing, and serving of content.
I'm trying to do the following:
I have website like apartments.com.
sometimes, I want to expand to different cities, so for SEO purposes, I might create a separate domain like bostonapartments.com or newyorkapartments.com for only boston and new york apartments.
bostonapartments.com and the main domain apartments.com are all hosted on 1 server. what I did was I used Virtual Host apache config to direct bostonapartments.com to a directory on that server, and then used an iframe to load content for bostonapartments.com from apartments.com. So all the content will be hosted on apartments.com, but bostonapartments.com will get the content from apartments.com.
how can I accomplish this effectively in a scalable way using php, apache, mysql?
btw, I do not own apartments.com, I'm just using that as an example.
Why such a contrived solution? Just add ServerAlias directives for all of your domains straight in the apartments.com virtual host.
if they are all identical it will do more bad than good due to duplicate content, but as #lanzz said, ServerAlias will do the same thing.
I would suggest separate
virtual servers and optimize each site with keywords, writing, etc etc.