我在启动Nginx服务时出现错误以下错误
在/ etc / nginx / sites-enabled / abc:1 中不允许使用“http”指令这是我的abc配置
worker_processes 1;
error_log /usr/local/openresty/nginx/logs/lua.log debug;
events {
worker_connections 1024;
}
http {
upstream kibana {
server server1:30001;
server server2:30001;
keepalive 15;
}
server {
listen 8882;
location / {
ssl_certificate /etc/pki/tls/certs/ELK-Stack.crt;
ssl_certificate_key /etc/pki/tls/private/ELK-Stack.key;
ssl_session_cache shared:SSL:10m;
auth_basic "Restricted Access";
auth_basic_user_file /etc/nginx/htpasswd.users;
proxy_pass http://kibana;
proxy_redirect off;
proxy_buffering off;
proxy_http_version 1.1;
proxy_set_header Connection "Keep-Alive";
proxy_set_header Proxy-Connection "Keep-Alive";
}
}
}
- >仅供参考我在/ etc / nginx / sites-available中创建此文件并将其链接到 / etc / nginx / sites-enabled。我使用以下命令提供链接
sudo ln -s /etc/nginx/sites-available/abc /etc/nginx/sites-enabled/abc
在上面的命令之后,我可以看到在/ etc / nginx / sites-enabled目录中创建了一个链接。
请建议我做错了什么?
此致 VG
答案 0 :(得分:0)
http指令不属于那里。
在ngnix.conf中,你已经有了http指令
http {
..config logs ...
inclide etc/ngnix/sites-enabled/*; <--- This Line include your files
.. more config...
server {
(..default server ...)
location / {
index
root
}
}
}
启用的站点中的文件只能包含服务器,http指令属于主体配置。 我会尝试:
events {
worker_connections 1024;
}
upstream kibana {
server server1:30001;
server server2:30001;
keepalive 15;
}
error_log /usr/local/openresty/nginx/logs/lua.log debug;
listen 8882;
location / {
basic "Restricted Access";
auth_basic_user_file /etc/nginx/htpasswd.users;
proxy_pass http://kibana;
proxy_redirect off;
proxy_buffering off;
proxy_http_version 1.1;
proxy_set_header Connection "Keep-Alive";
proxy_set_header Proxy-Connection "Keep-Alive";
}
ssl_certificate /etc/pki/tls/certs/ELK-Stack.crt;
ssl_certificate_key /etc/pki/tls/private/ELK-Stack.key;
ssl_session_cache shared:SSL:10m;
}