Git Product home page Git Product logo

Comments (7)

jingmian avatar jingmian commented on August 24, 2024

可以,按照你以上的设置不变,当然fastcgi_pass php80:9000;也不需要改动,只需要在docker-composer.yml文件中${NGINX_HTTP_HOST_PORT}:8088,改为8088:8088

from dnmp.

SemiThin avatar SemiThin commented on August 24, 2024

当然可以,就这这样配置就行了,不过你这样肯定会报错的,可以把站点2的default去掉,或者两个站点的default都去掉,其他不用改

from dnmp.

jiker-burce avatar jiker-burce commented on August 24, 2024

目前状况:

  • 站点1
server {
    listen       8088;
    server_name  api1.website.test;
    root   /www/api1/public;
    index  index.php index.html index.htm;

    access_log  /var/log/nginx/nginx.api1.access.log  main;
    error_log  /var/log/nginx/nginx.api1.error.log  warn;

    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }

    location ~ \.php$ {
        fastcgi_pass   php:9000; 
        include        fastcgi-php.conf;
        include        fastcgi_params;
    }
}

  • 站点2
server {
    listen       8088;
    server_name  api2.website.test;
    root   /www/api2/public;
    index  index.php index.html index.htm;

    access_log  /var/log/nginx/nginx.api2.access.log  main;
    error_log  /var/log/nginx/nginx.api2.error.log  warn;

    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }

    location ~ \.php$ {
        fastcgi_pass   php:9000; 
        include        fastcgi-php.conf;
        include        fastcgi_params;
    }
}

  • nginx
    ports:
      - "${NGINX_HTTP_HOST_PORT}:8088"
      - "${NGINX_HTTPS_HOST_PORT}:443"
  • .env
NGINX_VERSION=1.19.1-alpine
NGINX_HTTP_HOST_PORT=80
NGINX_HTTPS_HOST_PORT=443
  • 宿主机 hosts
127.0.0.1 api1.website.test
127.0.0.1 api2.website.test

  • 浏览器访问api1.website.test结果:
该网页无法正常运作 api1.website.test 目前无法处理此请求。
HTTP ERROR 502

from dnmp.

xiahuan710 avatar xiahuan710 commented on August 24, 2024

我觉得你先要搞秦楚nginx的基本用法,先了解什么叫空主机头,然后再来说你主机配置的问题。

from dnmp.

jiker-burce avatar jiker-burce commented on August 24, 2024

我觉得你先要搞秦楚nginx的基本用法,先了解什么叫空主机头,然后再来说你主机配置的问题。

也试过了,配置空头(设置404),访问localhost 就是404,访问域名依旧是502

from dnmp.

jiker-burce avatar jiker-burce commented on August 24, 2024

排查到问题了,是开启了vpn导致127.0.0.1 自动转发到本地的vpn端口上了。
通过观察浏览器console请求可以发现问题。

之前我的配置没啥问题;空头主机不配置也没啥关系。

from dnmp.

jiker-burce avatar jiker-burce commented on August 24, 2024

经研究,解决开发需要关闭vpn的问题

  • 打开mac的网络设置
  • 找到Wi-Fi 顶部的「详细信息」
  • 找到「代理」
  • 找到「忽略这些主机与域的代理设置」
  • 添加*.test
    点击「好」

此时,打开vpn也不会出现502了。另外,感谢各位的回复。

from dnmp.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.