0
votes

I have a VPS server and try to install Apache and Nginx to work together in Ubuntu 16.04 but with different server Names and domains.

So, I have apache to port 8000 and nginx to port 8080.

Nginx do go to 8080 port because use NodeJs and this uses behind the route https://localhost:8080/

Apache uses Laravel 5.5 and PHP.

I have already configure to Apache

/etc/apache2/sites-available/000.default.conf

<VirtualHost *:8000>
        ServerName www.myanotherdomainname.com
        ServerAdmin webmaster@localhost
        DocumentRoot /var/www/laravel/public

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

/ect/apache2/ports.conf with Listen 8000

For Nginx in /etc/nginx/sites-available/default

location / {
    proxy_pass http://localhost:8080;
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection 'upgrade';
    proxy_set_header Host $host;
    proxy_cache_bypass $http_upgrade;
}

And

server {
    if ($host = www.mydomain.com) {
        return 301 https://$host$request_uri;
    } # managed by Certbot

    if ($host = mydomain.com) {
        return 301 https://$host$request_uri;
    } # managed by Certbot

    listen 80 default_server;
    listen [::]:80 default_server;
    server_name geckode.la www.mydomain.com;
    return 404; # managed by Certbot
}

In www.mydomain.com, the script.js run by NodeJs works fine

But in www.myanotherdomainname.com, return 404 Not Found nginx/1.10.3 (Ubuntu)

It doesn't even seem to run apache

I need to know the best way to run apache and nginx with Nodejs.

Apache status and Nginx are running without any problem.

Thanks

1

1 Answers

1
votes

It's just doing what you told it to do. Let's run through your config:

if ($host = www.mydomain.com) - Nope...

if ($host = mydomain.com) - Still nope...

return 404; - OK, Ooops, I mean HTTP/1.1 404 Not Found