"server" direct is not allowed here in /etc/nginx/conf.d/default.conf:1

Asked 2 years ago, Updated 2 years ago, 65 views

When I tried to configure the SSL server on Nginx, I got a title error.

Below are nginx.conf and default.conf.

nginx.conf

usernginx;
worker_processes auto;

error_log/var/log/nginx/error.log warn;
pid/var/run/nginx.pid;


events {
    worker_connections1024;
}


US>http{
    include/etc/nginx/mime.types;
    default_type application/octet-stream;

    log_format main'$remote_addr-$remote_user[$time_local]"$request"'
                      '$status$body_bytes_sent"$http_refer"'
                      '''$http_user_agent''''$http_x_forwarded_for";

    access_log/var/log/nginx/access.log main;

    sendfile on;
    # tcp_nopush on;

    keepalive_timeout65;

    gzip on;

    include/etc/nginx/conf.d/*.conf;

    server_tokens off;
}

default.conf

server{
  listen80;
  listen [::]:80;
  return301 https://$host$request_uri;
}

server{
  listen443 ssl http2;
  listen [::]:443 ssl http2;
  ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
  server_name domain;

  ssl_certificate/etc/letsencrypt/live/domain/fullchain.pem;
  ssl_certificate_key/etc/letsencrypt/live/domain/privkey.pem;
  ssl_prefer_server_ciphers on;
  ssl_ciphers ECDHE+RSAGCM:ECDH+AESGCM:DH+AES256:DH+AES256:DH+AES256:DH+AES128:DH+AES:!aNULL!eNull:!EXPORT:!DES:!3DES:!MD5:!DSS;

  ssl_dhparam/etc/nginx/ssl/dhparam.pem;
  add_header Strict-Transport-Security 'max-age=31536000; includeSubDomains;';
  client_max_body_size64M;

  # Enable OCSP Stapling
  ssl_stapling on;
  ssl_stapling_verify on;
  ssl_trusted_certificate/etc/letsencrypt/live/domain/fullchain.pem;

  # DNS resolver must be specified for OCSP Stapling
  resolver 8.8.8.8;

  # Deny access to any files with a.php extension in the uploads directory
  location~*/(?:uploads|files)/.*\.php${
    deny all;
  }

  location / {
    proxy_pass http://127.0.0.1:port;
  }

  location^~/.well-known/acme-challenge/{
    root/usr/share/nginx/html;
  }

  location~.*\.(jpg|JPG|gif|GIF|png|PNG|swf|SWF|css|CSS|js|inc|INC|ico|ICO){
    root route;
  }
}

This error did not occur when SSL was not used.Why did I get this error?

nginx

2022-09-30 21:16

1 Answers

default.conf is included in http{} in nginx.conf, but
Have you included it elsewhere?


2022-09-30 21:16

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.