【问题标题】:Redirecting in NGNIX in localhost在 localhost 中的 NGINX 中重定向
【发布时间】:2020-03-11 14:59:46
【问题描述】:

我想当我在浏览器中写 10.10.0.0 时,它需要我索引页面。但它没有 我试过了

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

【问题讨论】:

    标签: nginx nginx-location nginx-config


    【解决方案1】:

    我没有时间测试,但请尝试关注

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

    【讨论】:

      【解决方案2】:

      让我们试着剖析它, 这在没有 docker 的情况下可以工作吗?

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

      注意:请参阅 “ports” 而不是“expose”,它告诉:“对于外部世界,我正在公开 8080,从那里我将在内部路由到容器中的端口 80”

        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 就无法工作,请检查 ngnixuwsgi(或其他)your_app 设置。

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

      【讨论】:

      • 版本:“3”服务:网络:图像:nginx 构建:。 ports: - "8080:80" tty: true expose: - "80" #这是容器网络环境内部的: - NGINX_HOST=localhost - NGINX_PORT=80 command: [nginx-debug, "-g", "daemon off; "]
      • 从 nginx 复制 .​​/ngnix.conf/ /etc/nginx/ngnix.conf
      猜你喜欢
      • 2015-10-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-08-14
      • 1970-01-01
      • 1970-01-01
      • 2021-06-28
      • 1970-01-01
      相关资源
      最近更新 更多