[英]Can't configure nginx reverse proxy
I'm running php+nginx api inside docker container.我在 docker 容器中运行 php+nginx api。 It is available on port 8080. I trying to add nginx reverse proxy to open api on address api.versite.online and frontend project on versite.online.它在端口 8080 上可用。我尝试添加 nginx 反向代理以打开地址 api.versite.online 上的 api 和 versite.online 上的前端项目。
I installed nginx on server, added /etc/nginx/sites-available/api.versite.online
config (also added symlink to sites-enabled directory), tested config with nginx -t
, restarted nginx service with systemctl reload nginx
, but it had no effect.我在服务器上安装了 nginx,添加了/etc/nginx/sites-available/api.versite.online
配置(还向启用站点的目录添加了符号链接),使用nginx -t
测试了配置,使用systemctl reload nginx
重新启动了 nginx 服务,但是它没有效果。 api.versite.online:8080 and versite.online:8080 makes request to docker container, looks like top level nginx are ignored. api.versite.online:8080 和 versite.online:8080 向 docker 容器发出请求,看起来顶级 nginx 被忽略了。 Nginx access log is empty. Nginx 访问日志为空。
/etc/nginx/sites-available/api.versite.online config /etc/nginx/sites-available/api.versite.online 配置
server {
listen 80;
server_name api.versite.online;
access_log /var/log/nginx/api.versite.access.log;
location / {
proxy_pass http://localhost:8080;
}
}
It seems that i forgot to add a firewall rule with sudo ufw allow 'Nginx HTTP'
看来我忘了用sudo ufw allow 'Nginx HTTP'
添加防火墙规则
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.