Xray-examples icon indicating copy to clipboard operation
Xray-examples copied to clipboard

"user" directive is not allowed here in /etc/nginx/conf.d/default.conf:1

Open mhnhh123 opened this issue 3 years ago • 0 comments
trafficstars

配置文件路径为

/etc/nginx/conf.d/default.conf

配置文件内容为

user nginx; worker_processes auto; error_log /var/log/nginx/error.log; pid /run/nginx.pid;

include /usr/share/nginx/modules/*.conf;

events { worker_connections 1024; }

http { log_format main '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for" ' '$proxy_protocol_addr:$proxy_protocol_port';

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

sendfile            on;
tcp_nopush          on;
tcp_nodelay         on;
keepalive_timeout   65;
types_hash_max_size 2048;

include             /etc/nginx/mime.types;
default_type        application/octet-stream;

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

server {
    #listen       80 default_server;
    #listen       [::]:80 default_server;
    listen       [::]:80 default ipv6only=off;
    return       301 https://$http_host$request_uri;
}

server {
    listen       unix:/dev/shm/default.sock proxy_protocol;
    listen       unix:/dev/shm/h2c.sock http2 proxy_protocol;

    # 把example.com换成你的域名
    server_name  xx.example.com;

    root         /usr/share/nginx/html;

    set_real_ip_from 127.0.0.1;


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

    # 开启 HSTS ,混 sslab 的 A+
    add_header Strict-Transport-Security "max-age=63072000" always;

    error_page 404 /404.html;
        location = /40x.html {
    }

    error_page 500 502 503 504 /50x.html;
        location = /50x.html {
    }
}

}

重启nginx报错 root@VM-o4SvqT80FlA1:~# systemctl status nginx.service ● nginx.service - nginx - high performance web server Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled) Drop-In: /etc/systemd/system/nginx.service.d └─override.conf Active: failed (Result: exit-code) since Wed 2022-08-17 04:04:09 UTC; 7s ago Docs: https://nginx.org/en/docs/ Process: 14244 ExecStart=/usr/sbin/nginx -c /etc/nginx/nginx.conf (code=exited, status=1/FAILURE) CPU: 4ms

Aug 17 04:04:09 VM-o4SvqT80FlA1 systemd[1]: Starting nginx - high performance web server... Aug 17 04:04:09 VM-o4SvqT80FlA1 nginx[14244]: nginx: [emerg] "user" directive is not allowed here in /etc/nginx/conf.d/default.conf:1 Aug 17 04:04:09 VM-o4SvqT80FlA1 systemd[1]: nginx.service: Control process exited, code=exited, status=1/FAILURE Aug 17 04:04:09 VM-o4SvqT80FlA1 systemd[1]: nginx.service: Failed with result 'exit-code'. Aug 17 04:04:09 VM-o4SvqT80FlA1 systemd[1]: Failed to start nginx - high performance web serve

配置文件路径

mhnhh123 avatar Aug 17 '22 04:08 mhnhh123