I have nginx setup on my vps with a static ip and 2 domains (beryju.org and nope.berlin).
I want to serve:
- Site 1 to beryju.org
- Site 2 to blog.beryju.org
- Site 3 to i.beryju.org
- Site 4 to nope.berlin
Additionally I want beryju.org and blog.beryju.org to support SSL.
But with my current configuration, I am getting:
- Site 1 not at all
- Site 2 on beryju.org and blog.beryju.org
- Site 3 on i.beryju.org
- Site 4 on nope.berlin
I have tried and it also doesn't works when I remove the hostname from the listen statement, i.e.
listen i.beryju.org:80;
to
listen 80;
in every file.
beryjuorg-blog.conf
server {
listen blog.beryju.org:80;
listen blog.beryju.org:443 ssl;
ssl_certificate /home/beryju/SSL/nginx/beryju.org.cert;
ssl_certificate_key /home/beryju/SSL/nginx/beryju.org.key;
access_log /var/log/nginx/beryjuorg-blog.access.log;
error_log /var/log/nginx/beryjuorg-blog.error.log;
root /home/beryju/Apps/Ghost/;
index index.html index.htm index.php;
location / {
proxy_pass http://127.0.0.1:2368;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
beryjuorg-image-hoster.conf
server {
listen i.beryju.org:80;
server_name i.beryju.org;
access_log /var/log/nginx/beryjuorg-image-hoster.access.log;
error_log /var/log/nginx/beryjuorg-image-hoster.error.log;
root /usr/share/nginx/i.beryju.org;
index index.html index.htm index.php;
location /gyazo.php {
try_files $uri $uri/ =404;
fastcgi_index index.php;
include fcgi.conf;
fastcgi_pass unix:/var/run/php-fcgi-beryjuorg-image-hoster-php-fcgi-0.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
location / {
try_files $uri $uri/ =404;
}
}
beryjuorg.conf
server {
listen beryju.org:80;
listen beryju.org:443 ssl;
ssl_certificate /home/beryju/SSL/nginx/beryju.org.cert;
ssl_certificate_key /home/beryju/SSL/nginx/beryju.org.key;
server_name beryju.org;
access_log /var/log/nginx/beryjuorg.access.log;
error_log /var/log/nginx/beryjuorg.error.log;
root /usr/share/nginx/beryju.org/;
index index.html index.htm index.php;
location ~ [^/]\.php(/|$) {
fastcgi_index index.php;
include fcgi.conf;
fastcgi_pass unix:/var/run/php-fcgi-beryjuorg-php-fcgi-0.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
}
nopeberlin.conf
server {
listen nope.berlin:80;
server_name nope.berlin;
access_log /var/log/nginx/nopeberlin.access.log;
error_log /var/log/nginx/nopeberlin.error.log;
root /usr/share/nginx/nope.berlin/;
index index.html index.htm index.php;
location / {
autoindex on;
}
}