Comments (7)
可以,按照你以上的设置不变,当然fastcgi_pass php80:9000;
也不需要改动,只需要在docker-composer.yml
文件中${NGINX_HTTP_HOST_PORT}:8088
,改为8088:8088
from dnmp.
当然可以,就这这样配置就行了,不过你这样肯定会报错的,可以把站点2的default去掉,或者两个站点的default都去掉,其他不用改
from dnmp.
目前状况:
- 站点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.
我觉得你先要搞秦楚nginx的基本用法,先了解什么叫空主机头,然后再来说你主机配置的问题。
from dnmp.
我觉得你先要搞秦楚nginx的基本用法,先了解什么叫空主机头,然后再来说你主机配置的问题。
也试过了,配置空头(设置404),访问localhost 就是404,访问域名依旧是502
from dnmp.
排查到问题了,是开启了vpn导致127.0.0.1 自动转发到本地的vpn端口上了。
通过观察浏览器console请求可以发现问题。
之前我的配置没啥问题;空头主机不配置也没啥关系。
from dnmp.
经研究,解决开发需要关闭vpn的问题
- 打开mac的网络设置
- 找到Wi-Fi 顶部的「详细信息」
- 找到「代理」
- 找到「忽略这些主机与域的代理设置」
- 添加
*.test
点击「好」
此时,打开vpn也不会出现502了。另外,感谢各位的回复。
from dnmp.
Related Issues (20)
- nginx.conf的问题 HOT 3
- 关于修复memcached版本的问题 HOT 1
- es数据文件挂载不出来
- 安装报错了,修改了yml文件里的端口重新拉取还是一样报错 HOT 1
- php8.3有计划么? HOT 3
- 手动安装的容器,如何在启动dnmp的时候也默认启动 HOT 1
- 新版本构建php和nginx容器报错 HOT 1
- WordPress安装时,MySQL的IP获取 HOT 1
- php扩展安装不成功 HOT 4
- 构建php82时报错,这个fix bug的命令可以撤掉吗? HOT 2
- 构建php82时报错,这个fix bug的命令可以撤掉吗?
- docker-compose up执行时报错 HOT 1
- docker-compose up -d HOT 2
- 在wsl环境下重启后服务无法自启动 HOT 1
- 安装swoole、rdkafka 出现问题 HOT 2
- 安装不了swoole HOT 1
- 配置多域名不会生效 HOT 3
- 是否有兴趣做多语言的加入go等 HOT 1
- Redis服务器版本:Connection refused HOT 2
- m1上构建异常no matching manifest for linux/arm64/v8 in the manifest list entries
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dnmp.