A
A
account-42017-03-10 23:08:55
Nginx
account-4, 2017-03-10 23:08:55

What is the basic config for Express?

Setup: application on Express, Ubuntu 16.04 on ES2, nginx + own domain (Elastic IP indicated in A record).
I have the simplest config in /etc/nginx/sites-available:

server {
    listen 80;

    server_name localhost;

    location / {
        proxy_pass http://localhost:3000;
        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;
    }
}

At the moment, everything started and works without any complaints at all. I didn't touch anything else from the settings. But there are a couple of issues:
1. It's not entirely clear with server_name localhost . In many examples, including the documentation on the site, localhost is replaced by the domain where the application should be accessible. Everything works for me without this instruction. Should I change to server_name example.com ? If so, why, if it works anyway?
2. Have I placed this config correctly in /etc/nginx/sites-available? I didn't write anything anywhere else. Again, there is controversy. Each tutorial has different places where to place the config (for example, place default.conf directly in the /etc/nginx/ folder). In addition, they say you still need to specify in sites-enabled . Is it all necessary?
3. What else can you advise to add / correct in the config?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrey Burov, 2017-03-10
@account-4

1) How nginx processes requests
2) sites-enabled usually symlink to sites-available, nginx.conf includes files from sites-enabled.
3) proxy_cache_bypass is needed if caching is configured nginx.org/en/docs/http/ngx_http_proxy_module.html#...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question