Я хочу передать запрос на прокси-сервер HTTP, директива proxy_pass указана внутри местоположения.
И в моем /etc/nginx/nginx.conf
я настраиваю:
server { location ~ ^/api/(.*)$ {
listen 80;
listen [::]:80;
location ~ ^/api/(.*)$ {
proxy_pass 127.0.0.1:8080;
}
}
}
И когдаЯ выполняю эту команду service nginx start
:
Job for nginx.service failed because the control process exited with error code.
See "systemctl status nginx.service" and "journalctl -xe" for details.
Вывод systemctl status nginx.service
● nginx.service - A high performance web server and a reverse proxy server
Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Sat 2019-11-02 20:25:51 UTC; 53s ago
Docs: man:nginx(8)
Process: 12219 ExecStop=/sbin/start-stop-daemon --quiet --stop --retry QUIT/5 --pidfile /run/nginx.pid (code=exited, status=0/SUCCESS)
Process: 9516 ExecReload=/usr/sbin/nginx -g daemon on; master_process on; -s reload (code=exited, status=0/SUCCESS)
Process: 11760 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
Process: 27870 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=1/FAILURE)
Main PID: 11763 (code=exited, status=0/SUCCESS)
Nov 02 20:25:51 ubuntu-s-milos2611 systemd[1]: Starting A high performance web server and a reverse proxy server...
Nov 02 20:25:51 ubuntu-s-milos2611 nginx[27870]: nginx: [emerg] invalid URL prefix in /etc/nginx/nginx.conf:72
Nov 02 20:25:51 ubuntu-s-milos2611 nginx[27870]: nginx: configuration file /etc/nginx/nginx.conf test failed
Nov 02 20:25:51 ubuntu-s-milos2611 systemd[1]: nginx.service: Control process exited, code=exited status=1
Nov 02 20:25:51 ubuntu-s-milos2611 systemd[1]: nginx.service: Failed with result 'exit-code'.
Nov 02 20:25:51 ubuntu-s-milos2611 systemd[1]: Failed to start A high performance web server and a reverse proxy server.