Using nginx with chocolatey simple server on IIS doesnt install/download package from choco.example.com/chocolatey

29 views Asked by At

I have an issue: I have chocolatey simple server in a machine in IIS. It works ok when using a https://example.com:5151 which is a domain that resovles in our public ip (DDNS) and the port that is directly open from the router to the IIS machine.

I wanted to use our ngnix proxy that is in another machine. I have configured a second domain in the nginx https://choco.example.com that resolves in our public ip but the nginx passes it to the internal ip of the machine that has the IIS and the port of chocolatey. For example https://choco.example.com -> http:/localipofmachine:5151. While its completely accesible from outside i have a problem when trying to use choco install with source : https://choco.example.com/chocolatey (it worked with the other domain that has direct access https://example.com:5151/chocolatey). The error i get is this :

2023-12-13 11:14:52,398 6332 [DEBUG] - _ Chocolatey:ChocolateyInstallCommand - Normal Run Mode _
2023-12-13 11:14:52,407 6332 [INFO ] - Installing the following packages:
2023-12-13 11:14:52,413 6332 [INFO ] - meshagent
2023-12-13 11:14:52,418 6332 [INFO ] - By installing, you accept licenses for the packages.
2023-12-13 11:14:52,506 6332 [DEBUG] - Using 'https://choco.example.com/chocolatey'.
2023-12-13 11:14:52,845 6332 [DEBUG] - - Supports prereleases? 'True'.
2023-12-13 11:14:52,850 6332 [DEBUG] - - Is ServiceBased? 'True'.
2023-12-13 11:14:53,201 6332 [DEBUG] - Package 'meshagent' found on source 'https://choco.heads.ddns.net/chocolatey'
2023-12-13 11:15:14,295 6332 [ERROR] - meshagent not installed. An error occurred during installation:
 Unable to connect to the remote server
2023-12-13 11:15:14,306 6332 [INFO ] - meshagent package files install failed with exit code 1. Performing other installation steps.
2023-12-13 11:15:14,313 6332 [DEBUG] - No package information as package is null.
2023-12-13 11:15:14,365 6332 [DEBUG] - No package information to save as package is null.
2023-12-13 11:15:14,372 6332 [DEBUG] - Sending message 'HandlePackageResultCompletedMessage' out if there are subscribers...
2023-12-13 11:15:14,377 6332 [ERROR] - The install of meshagent was NOT successful.
2023-12-13 11:15:14,384 6332 [ERROR] - meshagent not installed. An error occurred during installation:
 Unable to connect to the remote server
2023-12-13 11:15:14,396 6332 [WARN ] - 
Chocolatey installed 0/1 packages. 1 packages failed.
 See the log for details (C:\ProgramData\chocolatey\logs\chocolatey.log).
2023-12-13 11:15:14,402 6332 [INFO ] - 
2023-12-13 11:15:14,408 6332 [ERROR] - Failures
2023-12-13 11:15:14,414 6332 [ERROR] -  - meshagent (exited 1) - meshagent not installed. An error occurred during installation:
 Unable to connect to the remote server
2023-12-13 11:15:14,420 6332 [DEBUG] - Sending message 'PostRunMessage' out if there are subscribers...
2023-12-13 11:15:14,431 6332 [DEBUG] - Exiting with 1

How can i make it work? Thank you

I tried this:

Adding header details : 
location /chocolatey/ {
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto $scheme;
    proxy_set_header Host $http_host;
    proxy_pass http://localipofmachine:5151;
}
0

There are 0 answers