Report this

What is the reason for this report?

nginx multiple websites on same port

Posted on July 8, 2017
r0g

By r0g

Hi,

i want to run two wordpress websites on one nginx server. Here is my config:

server {
    listen 80 default_server;
    listen [::]:80 default_server ipv6only=on;

    root /var/www/mywebsite1;
    index index.php index.html index.htm;

    server_name mywebsite1.de www.mywebsite1.de;

    location / {
	try_files $uri/ /index.php?$args;
    }
    error_page 404 /404.html;
    error_page 500 502 503 504 /50x.html;
    location = /50x.html {
        root /var/www/mywebsite1;
    }

    location ~ \.php$ {
        try_files $uri =404;
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass unix:/var/run/php5-fpm.sock;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
    }
}

Second config:

server {
    listen 80;
    listen [::]:80 ipv6only=on;

    root /var/www/mywebsite2;
    index index.php index.html index.htm;

    server_name mywebsite1.de www.mywebsite1.de;

    location / {
        try_files $uri/ /index.php?$args;
    }
    error_page 404 /404.html;
    error_page 500 502 503 504 /50x.html;
    location = /50x.html {
        root /var/www/mywebsite1;
    }

    location ~ \.php$ {
        try_files $uri =404;
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass unix:/var/run/php5-fpm.sock;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
    }
}

While both are enabled via ln -s only one of them is responding. So when i call mywebsite1.de it shows mywebsite1.de but when i call mywebsite2.de it also shows mywebsite1.de. Any ideas?

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Start building today

From GPU-powered inference and Kubernetes to managed databases and storage, get everything you need to build, scale, and deploy intelligent applications.