Comments (9)
You'll want to forward to port 8080 inside Docker, rather than port 80.
The Nginx config inside the Docker container exposes two ports: 80 and 8080. Port 80 is just there to forward to SSL/443 (i.e., you want to serve exclusively HTTPS content, and as a convenience, auto redirect people who hit the HTTP endpoint).
In your case, I believe you just want to forward the HTTP app (8080). So the following config I think should be what you want.
version: "3.9"
services:
nginx:
image: openkilt/openrepo:latest
command: nginx
restart: unless-stopped
ports:
- "80:8080"
depends_on:
- "django"
volumes:
- ./openrepo-data:/var/lib/openrepo
from openrepo.
Nope
[root@openrepo openrepo]# cat docker-compose.yml | grep ports -A 1
ports:
- "80:8080"
[root@openrepo openrepo]# curl -v http://openrepo.opentech.local/infra-el8
* Trying 127.0.0.1...
* TCP_NODELAY set
* Connected to openrepo.opentech.local (127.0.0.1) port 80 (#0)
> GET /infra-el8 HTTP/1.1
> Host: openrepo.opentech.local
> User-Agent: curl/7.61.1
> Accept: */*
>
< HTTP/1.1 301 Moved Permanently
< Server: nginx/1.18.0 (Ubuntu)
< Date: Fri, 12 May 2023 16:37:02 GMT
< Content-Type: text/html
< Content-Length: 178
< Location: http://openrepo.opentech.local:8080/infra-el8/ <------ the same
< Connection: keep-alive
<
<html>
<head><title>301 Moved Permanently</title></head>
<body>
<center><h1>301 Moved Permanently</h1></center>
<hr><center>nginx/1.18.0 (Ubuntu)</center>
</body>
</html>
* Connection #0 to host openrepo.opentech.local left intact
from openrepo.
To be clear, the "repo" is only one page who acts like this. The OpenRepo web interface & API works as expected
from openrepo.
I tested and it works fine for me. One caveat seems to be that you need to upload a single package file to the repo. Before a RPM/Deb or generic file is uploaded, the repo directory doesn't yet exist and Nginx will return a 404.
I wonder if your docker images didn't get recreated when you ran docker-compose? From your command output, that port (8080) shouldn't even be open if you made the changes I posted.
Here is the full docker-compose.yml file I'm using for reference:
version: "3.9"
services:
nginx:
image: openkilt/openrepo:latest
command: nginx
restart: unless-stopped
ports:
- "80:8080"
depends_on:
- "django"
volumes:
- ./openrepo-data:/var/lib/openrepo
django:
image: openkilt/openrepo:latest
expose:
- "8000"
command: run_openrepoweb
restart: unless-stopped
volumes:
- ./openrepo-data:/var/lib/openrepo
environment:
- OPENREPO_DB_TYPE=postgresql
- OPENREPO_PG_DATABASE=openrepo
- OPENREPO_PG_USERNAME=postgres
- OPENREPO_PG_PASSWORD=postgres
- OPENREPO_PG_HOSTNAME=db
depends_on:
- "db"
worker:
image: openkilt/openrepo:latest
command: ./django/manage.py runworker
volumes:
- ./openrepo-data:/var/lib/openrepo
restart: unless-stopped
environment:
- OPENREPO_DB_TYPE=postgresql
- OPENREPO_PG_DATABASE=openrepo
- OPENREPO_PG_USERNAME=postgres
- OPENREPO_PG_PASSWORD=postgres
- OPENREPO_PG_HOSTNAME=db
depends_on:
- "django"
db:
image: postgres:15.1
expose:
- "5432"
restart: unless-stopped
environment:
- POSTGRES_PASSWORD=postgres
- POSTGRES_USER=postgres
- POSTGRES_DB=openrepo
volumes:
- ./openrepo-data/postgres:/var/lib/postgresql/data
from openrepo.
I tested and it works fine for me. One caveat seems to be that you need to upload a single package file to the repo. Before a RPM/Deb or generic file is uploaded, the repo directory doesn't yet exist and Nginx will return a 404.
Yes, it is
I wonder if your docker images didn't get recreated when you ran docker-compose? From your command output, that port (8080) shouldn't even be open if you made the changes I posted.
Here is the full docker-compose.yml file I'm using for reference:
I'm removed all openrepo
data, copy this reference and start build's again for fresh packages
Check that packages exists:
[root@openrepo openrepo]# curl http://openrepo.opentech.local/infra-el8/
<html>
<head><title>Index of /infra-el8/</title></head>
<body>
<h1>Index of /infra-el8/</h1><hr><pre><a href="../">../</a>
<a href="repodata/">repodata/</a> 19-May-2023 08:34 -
<a href="ethq-0.6.2-1.el8.x86_64.rpm">ethq-0.6.2-1.el8.x86_64.rpm</a> 19-May-2023 08:25 71292
<a href="public.gpg">public.gpg</a> 19-May-2023 08:34 1648
<a href="sst-1.7.237-1.el8.x86_64.rpm">sst-1.7.237-1.el8.x86_64.rpm</a> 19-May-2023 08:34 57348328
</pre><hr></body>
</html>
Then check for original issue (same request without trailing slash):
[root@openrepo openrepo]# curl -Ss -v http://openrepo.opentech.local/infra-el8 | grep Location
* Trying 127.0.0.1...
* TCP_NODELAY set
* Connected to openrepo.opentech.local (127.0.0.1) port 80 (#0)
> GET /infra-el8 HTTP/1.1
> Host: openrepo.opentech.local
> User-Agent: curl/7.61.1
> Accept: */*
>
< HTTP/1.1 301 Moved Permanently
< Server: nginx/1.18.0 (Ubuntu)
< Date: Fri, 19 May 2023 09:00:03 GMT
< Content-Type: text/html
< Content-Length: 178
< Location: http://openrepo.opentech.local:8080/infra-el8/ <--------- port still present
< Connection: keep-alive
<
{ [178 bytes data]
* Connection #0 to host openrepo.opentech.local left intact
from openrepo.
I apologize, maybe I'm misunderstanding. Are you saying that this URL works:
http://openrepo.opentech.local/infra-el8/
But this URL provides a redirect:
http://openrepo.opentech.local/infra-el8
to:
http://openrepo.opentech.local:8080/infra-el8/
The bug here being the reference to port 8080 instead of redirecting to: http://openrepo.opentech.local/infra-el8/
is that right?
from openrepo.
I apologize, maybe I'm misunderstanding. Are you saying that this URL works: http://openrepo.opentech.local/infra-el8/
But this URL provides a redirect: http://openrepo.opentech.local/infra-el8 to: http://openrepo.opentech.local:8080/infra-el8/
The bug here being the reference to port 8080 instead of redirecting to: http://openrepo.opentech.local/infra-el8/
is that right?
Exactly!
At least, because this port (obviously) unreachable:
√ ~ % curl -v http://openrepo.opentech.local/infra-el8
* Trying 100.100.101.22:80...
* Connected to openrepo.opentech.local (100.100.101.22) port 80 (#0)
> GET /infra-el8 HTTP/1.1
> Host: openrepo.opentech.local
> User-Agent: curl/7.88.1
> Accept: */*
>
< HTTP/1.1 301 Moved Permanently
< Server: nginx/1.18.0 (Ubuntu)
< Date: Mon, 22 May 2023 18:35:37 GMT
< Content-Type: text/html
< Content-Length: 178
< Location: http://openrepo.opentech.local:8080/infra-el8/
< Connection: keep-alive
<
<html>
<head><title>301 Moved Permanently</title></head>
<body>
<center><h1>301 Moved Permanently</h1></center>
<hr><center>nginx/1.18.0 (Ubuntu)</center>
</body>
</html>
* Connection #0 to host openrepo.opentech.local left intact
√ ~ % curl -v http://openrepo.opentech.local:8080/infra-el8/
* Trying 100.100.101.22:8080...
* connect to 100.100.101.22 port 8080 failed: Connection refused
* Failed to connect to openrepo.opentech.local port 8080 after 69 ms: Couldn't connect to server
* Closing connection 0
curl: (7) Failed to connect to openrepo.opentech.local port 8080 after 69 ms: Couldn't connect to server
from openrepo.
I pushed a change (commit c43f638) that hopefully resolves that issue. You can test it by either rebuilding the docker image and redeploying, or you can manually replace the config in your Nginx container and run:
/etc/init.d/nginx reload
from openrepo.
Seems this changes are not landed on latest
tag on docker hub
from openrepo.
Related Issues (16)
- Interested in Pulp Collaboration? HOT 1
- debian based operating system OS upgrade HOT 2
- multiple versions of packages HOT 4
- Ability to sort packages in the repo view by name
- Repo Builds are not sorted by newest first
- A
- CSRF Error When Running Behind HAProxy
- Cannot login behind reverse proxy HOT 11
- curl on signed key for a repo as per repo instructions results in a 404 Not Found. HOT 14
- Enhancement: Make signing key available even before any packages are uploaded to the repository HOT 1
- [Suggestion] Update Repo Instructions to make them more 'copy&paste-able' HOT 1
- cli: lack of 'overwrite' param for upload command HOT 1
- Add a REST API option to sign package with repo's private key on package upload HOT 4
- rpm packages with same version but different releases are not distinguished and conflict HOT 4
- CLI unable to upload new package HOT 3
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 openrepo.