我正在尝试使用nginX制作反向负载均衡器代理服务器。
我在106.10.**.***:3000
和106.10.**.***:4000
处创建了快递服务器
当我运行systemctl start nginx.service
时,它返回了类似的错误
Job for nginx.service failed because the control process exited with error code. See "systemctl status nginx.service" and "journalctl -xe" for details.
root@airbnb-api:/etc/nginx/sites-enabled# systemctl start nginx.service
所以我尝试了下面的systemctl status nginx.service
events { }
http {
upstream backend {
server 106.10.**.***:3000;
server 106.10.**.***:4000;
}
server {
location / {
proxy_pass http://backend;
}
}
}
● nginx.service - A high performance web server and a reverse proxy server
Loaded: loaded (/lib/systemd/system/nginx.service; disabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Tue 2019-10-29 00:22:20 KST; 7s ago
Docs: man:nginx(8)
Process: 3634 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=1/FAILURE)
Oct 29 00:22:20 airbnb-api systemd[1]: Starting A high performance web server and a reverse proxy server...
Oct 29 00:22:20 airbnb-api nginx[3634]: nginx: [emerg] "events" directive is not allowed here in /etc/nginx/sites-enabled/myapp.conf:1
Oct 29 00:22:20 airbnb-api nginx[3634]: nginx: configuration file /etc/nginx/nginx.conf test failed
Oct 29 00:22:20 airbnb-api systemd[1]: nginx.service: Control process exited, code=exited status=1
Oct 29 00:22:20 airbnb-api systemd[1]: Failed to start A high performance web server and a reverse proxy server.
Oct 29 00:22:20 airbnb-api systemd[1]: nginx.service: Unit entered failed state.
Oct 29 00:22:20 airbnb-api systemd[1]: nginx.service: Failed with result 'exit-code'.
我已经检查过106.10.**.***:3000
106.10.**.***:4000
,它们运行良好。
尝试sudo lsof -i:80
两个代码均成功返回
nginx -t -c /etc/nginx/sites-available/myapp.conf
nginx -t -c /etc/nginx/sites-enabled/myapp.conf
答案 0 :(得分:0)
您的事件指令存在配置问题
/etc/nginx/sites-enabled/myapp.conf:1 中不允许使用“事件”指令