在本地主机的 NGINX 中重定向

Redirecting in NGNIX in localhost

我想当我在浏览器中写 10.10.0.0 时,它需要我索引 page.but 它没有 我试过了

server {
  listen 8080;
    server_name 10.10.0.0;
     return 301 http://localhost:8080/index.html;
    }

我没有时间测试,但请尝试以下

server {
  listen 8080;
  server_name 10.10.0.0;
  location / {
     return 301 http://localhost:8080/index.html;
  }
}

让我们试着剖析一下, 这在没有 docker 的情况下是否有效?

如果是,让我们看看您的容器将哪些端口暴露给外界 例如:在 docker-compose 中你需要像下面这样公开它,

注意:请参阅 "ports" 而不是 "expose",它说明:"For external world I am exposing 8080, from there I will route internally to port 80 in the container"

  nginx:
    build:
       context: ./nginx
       dockerfile: Dockerfile
    command: /usr/sbin/nginx -g 'daemon off;' -c /etc/nginx/nginx.conf
    container_name: my_nginx_server
    tty: true
    expose:
        - "80" #This is internal to container network
    ports:
     - "8080:80" #HOST:CONTAINER

如果您使用的是命令行,那么它应该有“-p 8080:80”而 运行 容器

如果没有 docker 就无法工作,请检查 ngnix<-->uwsgi(或其他)<-->your_app 设置。

请分享更多信息,docker文件,docker-compose.yml