Hello,
I have 2 domain and 1 subdomain on 1 droplet (example1.com, example2.com, subdomain.example2.com).
This is my example1.com virtualhost:
#
# Redirect all www to non-www
#
server {
server_name www.example1.com;
ssl_certificate /etc/letsencrypt/live/example1.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/example1.com/privkey.pem;
listen *:80;
listen *:443 ssl spdy;
listen [::]:80;
listen [::]:443 ssl spdy;
return 301 https://example1.com$request_uri;
}
#
# Redirect all non-encrypted to encrypted
#
server {
server_name example1.com;
listen *:80;
listen [::]:80;
return 301 https://example1.com$request_uri;
}
server {
server_name example1.com;
listen *:443 ssl spdy;
listen [::]:443 ssl spdy;
root /var/www/html/blog;
...
}
This is my example2.com virtualhost:
server {
server_name example2.com;
root /var/www/html/example2.com;
...
}
This is my subdomain.example2.com virtualhost:
server {
listen [::]:80;
server_name subdomain.example2.com;
root /var/www/html/subdomain.example2.com;
...
}
There are no problem when I browser example1.com and example2.com, but when I go to subdomain.example2.com the browser make a redirect to example1.com
I try clean the browsers cache and nothing.
Greetings.
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
This comment has been deleted
Maybe you (or a browser plugin) was trying https://subdomain.example2.com and it went to example1 because exmple2 isn’t listening on 443. I have a browser plugin that auto changes http to https unless there is an error. And nginx would return the example1 as the best match on 443 rather than an error.
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.