I have installed nginx and I want to serve two different web applications under the same user on the same server.
This is the config I already use:
server {
listen 443 ssl;
server_name example.com;
ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;
return 301 https://www.example.com$request_uri;
}
# HTTPS — proxy all requests to the Node app
server {
# Enable HTTP/2
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name www.example.com;
location ~* \.(?:ico|css|js|gif|jpe?g|png)$ {
expires 30d;
add_header Vary Accept-Encoding;
access_log off;
}
root /home/myuser/main/dist;
# Use the Let’s Encrypt certificates
ssl_certificate /etc/letsencrypt/live/www.example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/www.example.com/privkey.pem;
# Include the SSL configuration from cipherli.st
include snippets/ssl-params.conf;
}
As you can see, I have under /home/myuser directory a directory called main and a dist directory in it. There there are static files that are successfully served using nginx.
I want to add another directory under the myuser directory, called for example, test.
So I will have /myuser/test and there to server another web application. Using the very same nginx server.
I have tried to write many variants in the config file I mentioned above but it couldn't work.
The config file located in: /etc/nginx/sites-enabled/example.com.conf
I edit it using sudo.