Skip to content

Instantly share code, notes, and snippets.

@a60814billy
Last active March 7, 2020 09:12
Show Gist options
  • Save a60814billy/b3d0e7b655e1243690dad0373c3b1973 to your computer and use it in GitHub Desktop.
Save a60814billy/b3d0e7b655e1243690dad0373c3b1973 to your computer and use it in GitHub Desktop.
<!-- /var/www/main-site/index.html -->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>Main Product Site</title>
<body>
<h1>Hello !</h1>
<script>
document.write(location.search);
</script>
</body>
</html>
# /etc/nginx/sites-available/main.conf
server {
server_name www.product.com;
location / {
root /var/www/main-site;
}
}
# /etc/nginx/sites-available/reseller.conf
include reseller_map.conf;
server {
server_name md.example.com user1.example.com;
rewrite ^(.*)$ http://www.product.com$1?proxy=$seller_id last;
return 302;
}
server {
server_name apple.example.com;
server_name orange.example.com;
rewrite ^(.*)$ http://www.product.com$1?proxy=$seller_id last;
return 302;
}
# /etc/nginx/reseller_map.conf
map $http_host $seller_id {
hostnames;
default "0";
md.example.com "md001";
user1.example.com "user";
apple.example.com "apple-pen";
orange.example.com "org";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment