我有两个应用程序-app1在localhost / app1上运行。暴露api的app2在localhost / app2上运行。这两个应用都使用nginx服务器。 App1是向app2发出HTTP GET请求,从而引发cURL错误7:连接失败。
但是当将这两个应用容器化(并在同一网络上运行)时,app1应该发送什么网址以获取api详细信息?
Docker-compose.yml
version: '2'
services:
web:
image: nginx
ports:
- "83:80"
- "443:443"
links:
- php
volumes:
- /code:/var/www/html
php:
build:
context: .
dockerfile: ./Dockerfile
volumes:
- /code:/var/www/html
代码目录有两个文件夹app1和app2,其中app1是应用程序代码库,而app2是api代码库
安装在Web容器内的Virutalhost条目
server {
listen 80;
server_name default;
root /var/www/html;
index index.html index.php;
client_max_body_size 100M;
fastcgi_read_timeout 1800;
location / {
try_files $uri $uri/ /index.php$is_args$args;
}
location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
expires max;
log_not_found off;
access_log off; }
location ~ \.php$ {
try_files $uri =404;
include fastcgi_params;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_pass lamp_php_1:9000;
}
}