如何解决Nginx Docker和重定向问题
很抱歉,我知道这必须是基本的,但我的目标是键入hostname
并重定向到主机名:8080(管理员实例)。
docker-compose.yml
version: '3.7'
services:
adminer:
image: adminer
hostname: adminer
container_name: adminer
ports:
- 8080:8080
restart: always
nginx:
image: nginx:alpine
container_name: nginx
volumes:
- ./nginx.conf:/etc/nginx/nginx.conf
ports:
- 80:80
- 443:443
depends_on:
- adminer
nginx.conf
events {
worker_connections 1024;
}
http {
server {
listen 80;
server_name localhost 127.0.0.1;
location / {
proxy_pass http://127.0.0.1:8080/;
proxy_set_header X-Forwarded-For $remote_addr;
}
}
}
当前,如果我输入localhost
,它将仅显示默认的Nginx页面。
感谢您的帮助。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。