Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failed to open stream: connection timed out, when use docker behind company proxy. #364

Open
aef5748 opened this issue Aug 19, 2024 · 5 comments
Labels
documentation Improvements or additions to documentation

Comments

@aef5748
Copy link

aef5748 commented Aug 19, 2024

My nextcloud is setup on the docker behind company proxy.
After installed app_api then try to test_deploy, but got the following message:

file_get_contents(https://raw.githubusercontent.com/cloud-py-api/test-deploy/main/appinfo/info.xml): Failed to open stream: Connection timed out at /var/www/html/custom_apps/app_api/lib/Service/ExAppService.php#277

Use Nextcloud to download others app successfully, so I think the network is workable.
How can I solved it?

NC: 29.0.3-apache
Appapi: 3.1.0

@bigcat88
Copy link
Member

bigcat88 commented Sep 6, 2024

Hello, sorry for the delay in replying.

If we can figure out how we can easily reproduce this in dev setups, then we can answer.
Are there any steps, what proxy should we set and how to configure it - what should we try?

@aef5748
Copy link
Author

aef5748 commented Sep 7, 2024

Deployment Steps:

  1. Deploy Nextcloud using Docker on a company network that has a proxy server.
  2. After configuring the proxy server authentication in Docker, reload the configuration file and restart Docker.
/etc/systemd/system/docker.service.d/http-proxy.conf
[Service]
Environment="HTTP_PROXY=http://username:[email protected]:3128"
Environment="HTTPS_PROXY=http://username:[email protected]:3128"
Environment="NO_PROXY=localhost,127.0.0.0/8,docker-registry.company.com"
  1. Set up the proxy server authentication in the docker-compose file to deploy Nextcloud, and update the certificates in the Nextcloud container to the company certificates, then restart the container.
docker-compose.yaml
version: '3.7'
networks:
  nextcloud:
    name: nextcloud_proxy
    driver: bridge
    
volumes:
  nexecloud:
  db:
  appapi:

services:
  db:
    image: postgres:12-alpine
    container_name: Nextcloud-DB
    restart: always
    volumes:
      - /home/sw/Nextcloud/db:/var/lib/postgresql/data
    environment:
      - POSTGRES_DB=nextcloud
      - POSTGRES_USER=nextcloud
      - POSTGRES_PASSWORD=nextcloud
      - TZ=Asia/Taipei
    networks:
      - nextcloud

  app:
    image: nextcloud:29.0.3-apache
    container_name: Nextcloud
    restart: always
    ports:
      - 3000:80
    depends_on:
      - db
      - appapi
    links:
      - db
      - appapi
    volumes:
      - /home/sw/Nextcloud/web:/var/www/html
      - /etc/localtime:/etc/localtime:ro
    environment:
      - POSTGRES_DB=nextcloud
      - POSTGRES_HOST=db
      - POSTGRES_USER=nextcloud
      - POSTGRES_PASSWORD=nextcloud
      - HTTP_PROXY=http://username:[email protected]:3128
      - HTTPS_PROXY=http://username:[email protected]:3128
      - NO_PROXY=localhost,127.0.0.0/8,docker-registry.company.com 
    networks:
      - nextcloud
      
  appapi:
    image: ghcr.io/cloud-py-api/nextcloud-appapi-dsp:release
    container_name: nextcloud-appapi-dsp
    hostname: nextcloud-appapi-dsp
    restart: unless-stopped
    privileged: true
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
    environment:
      - NC_HAPROXY_PASSWORD=nextcloud
      - TIMEOUT_SERVER=1800s
      - TIMEOUT_CONNECT=180s
      - TIMEOUT_CLIENT=180s
    ports:
      - 127.0.0.1:2375:2375
    networks:
      - nextcloud
  1. Download and install the appapi through the Nextcloud apps.
  2. After configuring the relevant parameters for appapi, click on "Test_deploy"
appapi config
ExApps installed: 1
Name: docker_socket_proxy
Protocol: http
Host: nextcloud-appapi-dsp:2375
 
Deploy config
Docker network: nextcloud_proxy
Nextcloud URL: http://192.168.101. 20:3000
HaProxy password: nextcloud
GPUs support: true
Compute device: CUDA

After setting up according to the steps above, an error message pops up.

file_get_contents(https://raw.githubusercontent.com/cloud-py-api/test-deploy/main/appinfo/info.xml): Failed to open stream: Connection timed out at /var/www/html/custom_apps/app_api/lib/Service/ExAppService.php#277 

I have also tried to manually execute the app registration, but there is a similar error message.

php occ app_api:app:register --force-scopes test-deploy docker_socket_proxy --info-xml https://raw.githubusercontent.com/cloud-py-api/test-deploy/main/appinfo/info.xml --test-deploy-mode --no-ansi --no-warnings

I tried downloading the info.xml of test_deploy and specifying it directly, which can successfully register, but an error occurs when downloading the test_deploy image.
Command:

php occ app_api:app:register --force-scopes test-deploy docker_socket_proxy --info-xml /var/www/html/info.xml --test-deploy-mode --no-ansi --no-warnings

Error message:

Failed to pull image, GuzzleException occur: Server error: `POST http://nextcloud-appapi-dsp:2375/v1.41/images/create?fromImage=ghcr.io%2Fcloud-py-api%2Ftest-deploy%3Arelease` resulted in a `504 Gateway Time-out` response 

P.S. When we download a file with https, we need skip certification verify.

@bigcat88
Copy link
Member

This is related to #371

I will update documentation for this, as the PROXY setting should be set for PHP CLI too and it should work after that.

@bigcat88
Copy link
Member

@aef5748 thanks for the explanation and patience. can you check if the linked pull request describes your situation and the suggested method fixes the installation for you?

thanks for the advice

@bigcat88 bigcat88 added the documentation Improvements or additions to documentation label Sep 23, 2024
andrey18106 pushed a commit that referenced this issue Sep 23, 2024
Should resolve these installation issues:
#364 and
#371

Signed-off-by: Alexander Piskun <[email protected]>
@aef5748
Copy link
Author

aef5748 commented Sep 24, 2024

I'm not sure if I have the settings correct, here are my steps:
The following message appears after using the php --ini command, and the Loaded Configuration File message is none.

Configuration File (php.ini) Path: /usr/local/etc/php
Loaded Configuration File:         (none)
Scan for additional .ini files in: /usr/local/etc/php/conf.d
Additional .ini files parsed:      /usr/local/etc/php/conf.d/docker-php-ext-apcu.ini,
/usr/local/etc/php/conf.d/docker-php-ext-bcmath.ini,
/usr/local/etc/php/conf.d/docker-php-ext-exif.ini,
/usr/local/etc/php/conf.d/docker-php-ext-ftp.ini,
/usr/local/etc/php/conf.d/docker-php-ext-gd.ini,
/usr/local/etc/php/conf.d/docker-php-ext-gmp.ini,
/usr/local/etc/php/conf.d/docker-php-ext-imagick.ini,
/usr/local/etc/php/conf.d/docker-php-ext-intl.ini,
/usr/local/etc/php/conf.d/docker-php-ext-ldap.ini,
/usr/local/etc/php/conf.d/docker-php-ext-memcached.ini,
/usr/local/etc/php/conf.d/docker-php-ext-opcache.ini,
/usr/local/etc/php/conf.d/docker-php-ext-pcntl.ini,
/usr/local/etc/php/conf.d/docker-php-ext-pdo_mysql.ini,
/usr/local/etc/php/conf.d/docker-php-ext-pdo_pgsql.ini,
/usr/local/etc/php/conf.d/docker-php-ext-redis.ini,
/usr/local/etc/php/conf.d/docker-php-ext-sodium.ini,
/usr/local/etc/php/conf.d/docker-php-ext-sysvsem.ini,
/usr/local/etc/php/conf.d/docker-php-ext-zip.ini,
/usr/local/etc/php/conf.d/nextcloud.ini,
/usr/local/etc/php/conf.d/opcache-recommended.ini,
/usr/local/etc/php/conf.d/proxy.ini
  1. Use docker Image => nextcloud:30.0.0-apache
  2. Add proxy.ini to the /usr/local/etc/php/conf.d directory, its content is as follows:
[HTTP]
http.proxy_host = "company.proxy.com"
http.proxy_port = 3128
http.proxy_user = "username"
http.proxy_password = "password"

[HTTPS]
https.proxy_host = "company.proxy.com"
https.proxy_port = 3128
https.proxy_user = "username"
https.proxy_password = "password"
  1. Restart the container
  2. Configure AppAPI
  3. Still getting the failure message
Calling occ(directory=null): 'app_api:app:register' '--silent' 'test-deploy' 'docker_socket_proxy' '--info-xml' 'https://raw.githubusercontent.com/cloud-py-api/test-deploy/main/appinfo/info.xml' '--test-deploy-mode' --no-ansi --no-warnings
file_get_contents(https://raw.githubusercontent.com/cloud-py-api/test-deploy/main/appinfo/info.xml): Failed to open stream: Connection timed out at /var/www/html/custom_apps/app_api/lib/Service/ExAppService.php#271

Using method 2 to modify the environment file, the same result is obtained.

http_proxy=http://username:[email protected]:3128
https_proxy=http://username:[email protected]:3128

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

2 participants