在本地主机的NGNIX中重定向

当我在浏览器中编写10.10.0.0时,我想要索引页。但是它没有 我尝试过

server {
  listen 8080;
    server_name 10.10.0.0;
     return 301 http://localhost:8080/index.html;
    }
qw12c 回答:在本地主机的NGNIX中重定向

我没有时间进行测试,但是请尝试

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

让我们尝试剖析它, 没有docker,这可以工作吗?

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

注意:参见“端口” 而不是“暴露”,它表明:“对于外部世界,我暴露8080,从那里我将内部路由到容器中的端口80” / em>

  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 设置。

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

本文链接:https://www.f2er.com/3095356.html

大家都在问