我很难弄清楚如何将proxypass
从nginx
容器转换为nodejs
容器。
在我看来,http://localhost:3000
将落在nginx
容器中......所以我认为这个设置是有意义的:
nginx
容器:
podman run -d \
--name nginx.main \
-p 0.0.0.0:8081:8080 \
-p 0.0.0.0:4431:4430 \
-p 0.0.0.0:3001:3000 \
-u root \
-v /home/_secrets/certbot/_certs:/etc/nginx/_cert \
-v /home/mee/_volumes/nginx_main:/etc/nginx \
nginx
字符串
nodejs
容器:
podman run -d \
-v /home/mee/dev/abd/:/usr/src/app -w /usr/src/app \
-p 3000:3000 \
--name next.dev node:latest \
npm run dev
型
firewalld
,从3001
路由到3000
:
sudo firewall-cmd --add-port=3000/tcp --permanent
sudo firewall-cmd --add-port=3001/tcp --permanent
sudo firewall-cmd --permanent \
--zone=mee_fd \
--add-forward-port=port=3001:proto=tcp:toport=3000
sudo firewall-cmd --reload
型
nginx
配置:
location / {
proxy_pass http://localhost:3000;
add_header X-Frame-Options "SAMEORIGIN" always;
add_header X-XSS-Protection "1; mode=block" always;
add_header X-Content-Type-Options "nosniff" always;
add_header Referrer-Policy "no-referrer-when-downgrade" always;
add_header Content-Security-Policy "default-src * data: 'unsafe-eval' 'unsafe-inline'" always;
# add_header Strict-Transport-Security "max-age=31536000; includeSubDomains; preload" always;
# enable strict transport security only if you understand the implications
}
型
真的不知道这应该如何通信.我已经尝试使用ipaddress
而不是'localhost',但我得到相同的响应.
谢谢
1条答案
按热度按时间vsdwdz231#
为了允许容器之间的通信,您需要设置一个共享网络,例如在.yaml中(这可以在ci上完成,仅出于代码目的在.yaml中报告):
字符串
在nginx配置中:
型
让我知道