Reputation: 1980
I am looking for a way to run two websites on top level domain on the same ECS instance. I am new to Alibaba Cloud and looking for best options to achieve this
Upvotes: 0
Views: 529
Reputation: 13
It depends on your OS (windows/linux) and web server (apache/nginx) that you need. For my experiences were using the NGINX web server with Ubuntu web server, here are the steps:
sudo nano /etc/nginx/site-enabled/example1
upstream example1 {
server unix:/run/uwsgi/exampple1.sock;
}
server {
listen 80;
server_name example1.com;
charset utf-8;
client_max_body_size 75M;
access_log /var/log/example1/example1.nginx.access.log;
error_log /var/log/example1/example1.nginx.error.log;
location /media {
alias /opt/apps/example1/files/media;
}
location /static {
alias /opt/apps/example1/files/static-collected;
}
location / {
uwsgi_pass example1;
include uwsgi_params;
}
}
sudo nano /etc/nginx/site-enabled/example2
server {
listen 80;
server_name example2.com;
charset utf-8;
client_max_body_size 75M;
access_log /var/log/example2/example2.nginx.access.log;
error_log /var/log/example2/example2.nginx.error.log;
root /opt/apps/example2; # YOUR LOCATION WEB RESOURCES
index index.php index.html index.htm index.nginx-debian.html;
location / {
try_files $uri $uri/ =404;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php7.0-fpm.sock;
}
location ~ /\.ht {
deny all;
}
}
Upvotes: 0
Reputation: 1622
There are different ways you can do that,
Before you do this, you need to map your top-level domains DNS 'A' records to the ECS instance public Internet IP. Now you have two approaches to do this.
One way is to you create only one single site which has the content of both and serve the pages you want to by recognizing the host using the HTTP headers in the request, but this makes your information exposed to the user. This approach is not secure.
The other and better way would be to containerize the websites and use the reverse proxy to map the website.
More detailed steps mentioned here:
Thanks
Upvotes: 0