I'm trying to use 1 DigitalOcean Droplet to host 2 different websites with 2 domains using NGINX Ubuntu 16.04. I tried to follow this tutorial https://www.digitalocean.com/community/tutorials/how-to-set-up-nginx-server-blocks-virtual-hosts-on-ubuntu-16-04
I own both domains that are pointing to the droplet. Let's say the domains are janedoe.com and johndoe.com. janedoe.com uses Lets Encrypt for tls. Johndoe.com does not use ssl/tls.
These are my sites-available configs:
Janedoe.com:
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name janedoe.com www.janedoe.com;
return 301 https://$server_name$request_uri;
# SSL configuration
include snippets/ssl-janedoe.com.conf;
include snippets/ssl-params.conf;
root /var/www/janedoe.com/html;
index index.php index.html;
error_page 404 /404.php;
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
location ~ \.php$ {
include snippets/fastcgi-php.conf;
# With php7.0-cgi alone:
# fastcgi_pass 127.0.0.1:9000;
# With php7.0-fpm:
fastcgi_pass unix:/run/php/php7.0-fpm.sock;
}
}
Johndoe.com:
server {
listen 80;
listen [::]:80 ipv6only=on;
server_name johndoe.com www.johndoe.com;
return 301 https://$server_name$request_uri;
root /var/www/johndoe.com/html;
index index.php index.html;
error_page 404 /404.php;
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
location ~ \.php$ {
include snippets/fastcgi-php.conf;
# With php7.0-cgi alone:
# fastcgi_pass 127.0.0.1:9000;
# With php7.0-fpm:
fastcgi_pass unix:/run/php/php7.0-fpm.sock;
}
}
I was also wondering if my /etc/hosts file was correct
# Your system has configured 'manage_etc_hosts' as True.
# As a result, if you wish for changes to this file to persist
# then you will need to either
# a.) make changes to the master file in /etc/cloud/templates/hosts.tmpl
# b.) change or remove the value of 'manage_etc_hosts' in
# /etc/cloud/cloud.cfg or cloud-config from user-data
#
127.0.1.1 doe-2gb-nyc1-01 doe-2gb-nyc1-01
# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts
Here is my /etc/nginx
user www-data;
worker_processes auto;
pid /run/nginx.pid;
events {
worker_connections 768;
# multi_accept on;
}
http {
##
# Basic Settings
##
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
# server_tokens off;
server_names_hash_bucket_size 64;
# server_name_in_redirect off;
include /etc/nginx/mime.types;
default_type application/octet-stream;
##
# SSL Settings
##
ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
ssl_prefer_server_ciphers on;
##
# Logging Settings
##
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
##
# Gzip Settings
##
gzip on;
gzip_disable "msie6";
# gzip_vary on;
# gzip_proxied any;
# gzip_comp_level 6;
# gzip_buffers 16 8k;
# gzip_http_version 1.1;
# gzip_types text/plain text/css application/json application/javascript text/xml applicati$
##
# Virtual Host Configs
##
include /etc/nginx/conf.d/*.conf;
# include /etc/nginx/sites-enabled/*;
}
My problem is visiting either site will redirect you to janedoe.com which says
This page isn’t working
janedoe.com redirected you too many times.
Try clearing your cookies.
ERR_TOO_MANY_REDIRECTS
I've cleared my cookies, used different browsers, etc.
Please let me know if there is any more information that would be helpful.
Thanks in advance.