0

i have captures on the code of config file and the exact location and the error itself

The error display The config script and the exact location of the file

i've tried to change port but it doesn't work i've created another config file thinking it's syntax error but it doesn't work either and i even changed listen :*80 to listen80 but nothing works.

what i want to do is to deploy the website and do 3 replicas.

1 Answers1

0

The keywords have to be separated by space from their values. If you use the IP part of the declaration, you have to separate the port by :

instead of

listen*80 default_server;
listen[::]:80 default_server;

write

listen  *:80  default_server;
listen  [::]:80  default_server;

But for your example, this should be enough:

listen  80  default_server;

Same thing comes to

  • location /{ –> location / {
  • server{ -> server {

Lax syntax is the first source for problems. It is very helpful to structure by intents:

server {
    listen      80  default_server;
    server_name mywebsite.com;
    root        /var/www/website/html/;

    location / {
        index       index.html;
    }
}

Preferably you should have defined the root directly in the server root definitions. So I also moved the root statement.

dodrg
  • 1,142
  • 2
  • 18
  • Well i still knowing how to use it so it happens and thank you for your answer i'll try it and let you know.also can you explain more about the root definition ? – Mouhamed Amine Mar 22 '23 at 17:13
  • You can define multiple times `location` with different paths or regex. If required you can define a different root within a `location` container, for example to store huge media files on a different filesystem. — But it's quite usefull to have the mother of all "DOCUMENT_ROOT" (= root) defined. And this is in the base of the `server { }` container. – dodrg Mar 22 '23 at 17:28
  • Has your problem been solved? – dodrg Mar 24 '23 at 14:36
  • unfortunalty it hasn't solved yet, i even recreated the file more than once but it doesn't work . – Mouhamed Amine Mar 25 '23 at 13:41
  • What do the logs say? Perhaps you should enable the nginx log: `error_log /var/log/nginx-error.log info;` – dodrg Mar 27 '23 at 11:36
  • Well what i have done is that i created it in default folder html near default.html – Mouhamed Amine Apr 08 '23 at 15:52
  • Please add the error_log. Everything else is more or less blind guessing. And is the tag `nginx-reverse-proxy` and `nginx-ingress` by purpose? — In the current config is nothing about it. – dodrg Apr 09 '23 at 21:03