I can't figure out the NGINX config to launch the site.
I can’t figure it out myself, all the same, there is not enough theoretical basis. Maybe you can advise.
env BACKEND_API;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
worker_processes 4;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
upstream backend {
server backend;
}
server {
set_by_lua $backend_url 'return os.getenv("BACKEND_API")';
listen 80;
server_name _;
server_tokens off;
client_max_body_size 100M;
location / {
root /www/html;
index index.html index.htm;
try_files $uri $uri/ /index.html;
}
location /api {
try_files $uri @proxy_api;
}
location @proxy_api {
proxy_set_header X-Forwarded-Proto https;
proxy_set_header X-Url-Scheme $scheme;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_pass $backend_url;
}
}
}
I get an error:
frontend | 2022/02/21 08:29:58 [error] 28#28: *2 no resolver defined to resolve backend, client: 31.176.83.92, server: _, request: "POST /api/auth HTTP/1.1", host: "194.86.154.183", referrer: "http://194.86.154.183/"
Can you please tell me where to look? Any advice and help is welcome.