I'm a web developer. When I start developing a website and my client's domain has to point to another server until the website I'm developing is ready, what I used to do was:
1) Add their domain to my server 2) Edit my hosts file and point the domain to my server's IP.
The problem with the above setup is, clients can't see the website I'm developing, so I created a domain to host their websites temporarily until they are ready. So:
mydomain.com/client1
mydomain.com/client2
mydomain.com/client3
Let's suppose I'm developing a website for xyz.com. To avoid having to do major changes to transfer the website from mydomain.com/xyz to xyz.com (which is also in my server), I want mydomain.com/client1 to load the files that are in the xyz root folder. This way transferring mydomain.com/xyz to xyz.com would be as simple as a dns record change.
So, this is my vhost for xyz.com:
server {
error_log /var/log/nginx/vhost-error_log warn;
listen 1.1.1.1:80;
server_name mydomain.com www.mydomain.com;
access_log /usr/local/apache/domlogs/mydomain.com-bytes_log bytes_log;
access_log /usr/local/apache/domlogs/mydomain.com combined;
root /home/mydomain/public_html;
location ^~ /xyz {
root /home/xyz/public_html;
}
location / {
location ~.*\.(3gp|gif|jpg|jpeg|png|ico|wmv|avi|asf|asx|mpg|mpeg|mp4|pls|mp3|mid|wav|swf|flv|html|htm|txt|js|css|exe|zip|tar|rar|gz|tgz|bz2|uha|7z|doc|docx|xls|xlsx|pdf|iso)$ {
expires 1d;
try_files $uri @backend;
}
error_page 405 = @backend;
add_header X-Cache "HIT from Backend";
proxy_pass http://1.1.1.1:8081;
include proxy.inc;
}
location @backend {
internal;
proxy_pass http://1.1.1.1:8081;
include proxy.inc;
}
location ~ .*\.(php|jsp|cgi|pl|py)?$ {
proxy_pass http://1.1.1.1:8081;
include proxy.inc;
}
location ~ /\.ht {
deny all;
}
}
Looks fine, but when I access it, I get this:
I also tried using alias, didn't work. Tried with and without the "^~".
What am I doing wrong?