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.
Related
I want use droplets to host multiple domains/sites, this is easy to do using virtual hosts, but how limit website X access files from directory of website Y?
In my droplet (testing), I have something like
/var/www/websiteX.com
/var/www/websiteY.com
/var/www/websiteZ.com
All working fine, but this websites using WordPress as CMS, so, users can install plugins and this is a problem, "deny access to directory of other website"...
I don't want give FTP/SSH access to each website.
There are options to turn on or off indexes in Apache. Here is a link that talks about it. https://www.techrepublic.com/article/how-to-make-apache-more-secure-by-hiding-directory-folders/
If you want to conditionally turn on or off indexes based on what domain a user is accessing I think you will have a very hard time.
Why are you trying to do this? You might want to reconsider trying to accomplish this.
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
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.
http://www.one.com
and
http://www.one.com/uk
www.one.com is the main site, but there is a UK version of this site which ideally needs to be in a subdirectory (/uk).
How do set IIS up to allow me to have multiple sites under one domain?
Or can I have two separate sites and use ISAPI_rewrite to point www.one.com/uk to read from another site but keep the url www.one.com/uk?
Could you not just setup a virtual directory that points at the second application? Assuming you are using asp.net, you'd have to make sure there was no overlap in the web.config files (you may have to remove/add some elements) but a virtual directory would be a simple solution I'd think.
You could just set up a virtual directory called "uk" inside the main site for "www.one.com", and place the UK version of the application inside it. You'll need to make sure that the application inside it either uses relative links (to make sure it does not stray out into the main application), or it's absolute links include the /uk/ prefix.
Alternatively, have you considered using two hostnames? E.g., www.one.com for global/ US/ non-UK, and uk.one.com for the UK site?
Just setup a virtual "/uk" directory. http://support.microsoft.com/kb/172138
You can do it with ISAPI_Rewrite with the proxy if you needed to use multiple domains but I would recommend if you had to use multiple domains doing it the easy way by making the second site : uk.one.com using host headers. http://www.visualwin.com/host-header/
Alternatively you could set up subdomain like uk.one.com and redirect user there if he is from uk. It's easier.
I currently host my company's website and blog on separate servers, reached by separate domain names - www.example.com and www.example.net. This is so I can give blog server access to our partners without compromising security on our main server. However, our SEO guy is now demanding that the blog be put on our main server, as www.example.com/blog.
I would like to maintain the current server separation rather than putting both on the same server. Is there any good way to keep them separated, but have them both under a single domain name? A subdomain would also be acceptable (blog.example.com).
My main website server is a Debian box running Apache 2, and I have full root access to it. The blog server is run by Hostgator, and I have limited access.
Edit: Thanks, all. In this particular situation I don't particularly want to transfer the blog again, and I don't have easy access to the DNS records, so i went with mod_proxy and it worked like a charm. I wish I could give you all "preferred answer" status, though, because all of your information was awesome.
A subdomain would be easy: just create an A record in DNS which maps blog.example.com to the IP address of the blog server, and have another A record in DNS which maps www.example.com to the main website server (this latter record probably already exists).
Would the SEO guy be happy with blog.example.com? It's not the same from an SEO perspective, but it might be good enough for him. I work at a company where SEO is at least 1/3 of what we do, and that's our setup: blog.example.com and www.example.com.
You could try to get fancy and proxy requests to /blog to the 2nd server, if you insist on keeping the blog off your box, but I think you can find a secure way to share space. Proxying like that could get annoying, and it basically doubles the latency to your blog.
Give the blog guys an account on your box; don't give them root/special privileges. If you can get away with it, don't even give them SSH access -- just give them a FTP login (make sure they can't access /var/www), and maybe a mysql account or something. (As you can see, this all depends on how much control/power the blog folks demand.)
Then, just make a symlink to the blog root, so they can write to a restricted area like /home/blog/www and still have it included in the website:
ln -s ~blog/www /var/www/blog
If a subdomain is for some reason not a possible way for you to go, you could use Apache's mod_proxy module to proxy requests to /blog to your second server.