C
Coder.com6d ago
e1k

Code market place setup

Hello, I would like to setup code market place, does some how have a poc for the tls reverse proxy ? I'm not really sure how to start.. Thanks
14 Replies
Codercord
Codercord6d ago
<#1306277796372414544>
Category
Help needed
Product
Coder OSS (v2)
Platform
Linux
Logs
Please post any relevant logs/error messages.
Phorcys
Phorcys6d ago
Hey @e1k, I'm not sure what you mean by "code market place", could you elaborate a bit?
e1k
e1kOP5d ago
Hello @Phorcys, i'm talking about this project : https://github.com/coder/code-marketplace Am I on the right discord ? I need to help for setup.
GitHub
GitHub - coder/code-marketplace: Open source extension marketplace ...
Open source extension marketplace for VS Code. Contribute to coder/code-marketplace development by creating an account on GitHub.
Phorcys
Phorcys5d ago
oh yeah definitely, I just wanted to make sure you weren't talking about Coder or code-server I'll get back to you later today will you be at the ECW next week? I see you're in some CTF Discord servers
e1k
e1kOP5d ago
I manage to get a working nginx config, but I need to use an other port, I can't use 3001, there 's already a container that I can't move. I belive there's something to do with nginx but I'm not expert enough to find an answer. Sadly, this year I can't make it, I'm too busy. But I have great memories from the past years !
Phorcys
Phorcys5d ago
that's too bad! could you send your config over?
e1k
e1kOP5d ago
I created a container containing nginx and code marketplace, nothing really fancy but I can share it if needed. This is my docker-compose :
services:
nginx_marketplace:
build:
context: .
dockerfile: Dockerfile
container_name: nginx-marketplace
ports:
- "80:80"
- "443:443"
- "9015:3001"
volumes:
- ./nginx.conf:/etc/nginx/nginx.conf:ro
- ./certs/:/etc/nginx/certs/:ro
- ./exts:/exts
services:
nginx_marketplace:
build:
context: .
dockerfile: Dockerfile
container_name: nginx-marketplace
ports:
- "80:80"
- "443:443"
- "9015:3001"
volumes:
- ./nginx.conf:/etc/nginx/nginx.conf:ro
- ./certs/:/etc/nginx/certs/:ro
- ./exts:/exts
And this my nginx config :
# /nginx.conf
events { }

http {
server {
listen 443 ssl;
server_name marketplace.lab.fr;

# Specify the paths to the mounted certificates
ssl_certificate /etc/nginx/certs/marketplace.crt;
ssl_certificate_key /etc/nginx/certs/marketplace.key;

location /marketplace/ {
proxy_pass http://192.168.111.62:9015/;

# Set headers required by the marketplace
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Proto $scheme;

proxy_set_header Forwarded "host=$host;proto=$scheme";
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}

}

# Redirect HTTP to HTTPS
server {
listen 80;
server_name marketplace.lab.fr;

return 301 https://$host$request_uri;
}
}
# /nginx.conf
events { }

http {
server {
listen 443 ssl;
server_name marketplace.lab.fr;

# Specify the paths to the mounted certificates
ssl_certificate /etc/nginx/certs/marketplace.crt;
ssl_certificate_key /etc/nginx/certs/marketplace.key;

location /marketplace/ {
proxy_pass http://192.168.111.62:9015/;

# Set headers required by the marketplace
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Proto $scheme;

proxy_set_header Forwarded "host=$host;proto=$scheme";
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}

}

# Redirect HTTP to HTTPS
server {
listen 80;
server_name marketplace.lab.fr;

return 301 https://$host$request_uri;
}
}
Phorcys
Phorcys5d ago
do you already have a working nginx/reverse-proxy instance that isn't this one?
e1k
e1kOP5d ago
Yes, wait a few sec It was pretty similar, using port 3001:3001 and proxy_pass http://127.0.0.1:3001/
Phorcys
Phorcys5d ago
I mean, what I usually do is have a single reverse-proxy for all containers, then have all the configs in the same place saves some time that said, i do not see any issue with this config, are you running into any particular issue?
e1k
e1kOP4d ago
yeah, this is just for poc, it was easier, on prod it will be two different one I m running into 502
nginx-marketplace | 2024/11/14 12:59:10 [error] 16#16: *9 recv() failed (104: Connection reset by peer) while reading response header from upstream, client: 172.18.0.1, server: marketplace.lab.fr, request: "GET /marketplace/ HTTP/1.1", upstream: "http://192.168.111.62:9015/", host: "127.0.0.1"
nginx-marketplace | 172.18.0.1 - - [14/Nov/2024:12:59:10 +0000] "GET /marketplace/ HTTP/1.1" 502 157 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:132.0) Gecko/20100101 Firefox/132.0"
nginx-marketplace | 2024/11/14 12:59:10 [error] 16#16: *9 open() "/etc/nginx/html/favicon.ico" failed (2: No such file or directory), client: 172.18.0.1, server: marketplace.lab.fr, request: "GET /favicon.ico HTTP/1.1", host: "127.0.0.1", referrer: "https://127.0.0.1/marketplace/"
nginx-marketplace | 172.18.0.1 - - [14/Nov/2024:12:59:10 +0000] "GET /favicon.ico HTTP/1.1" 404 153 "https://127.0.0.1/marketplace/" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:132.0) Gecko/20100101 Firefox/132.0"
nginx-marketplace | 2024/11/14 12:59:10 [error] 16#16: *9 recv() failed (104: Connection reset by peer) while reading response header from upstream, client: 172.18.0.1, server: marketplace.lab.fr, request: "GET /marketplace/ HTTP/1.1", upstream: "http://192.168.111.62:9015/", host: "127.0.0.1"
nginx-marketplace | 172.18.0.1 - - [14/Nov/2024:12:59:10 +0000] "GET /marketplace/ HTTP/1.1" 502 157 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:132.0) Gecko/20100101 Firefox/132.0"
nginx-marketplace | 2024/11/14 12:59:10 [error] 16#16: *9 open() "/etc/nginx/html/favicon.ico" failed (2: No such file or directory), client: 172.18.0.1, server: marketplace.lab.fr, request: "GET /favicon.ico HTTP/1.1", host: "127.0.0.1", referrer: "https://127.0.0.1/marketplace/"
nginx-marketplace | 172.18.0.1 - - [14/Nov/2024:12:59:10 +0000] "GET /favicon.ico HTTP/1.1" 404 153 "https://127.0.0.1/marketplace/" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:132.0) Gecko/20100101 Firefox/132.0"
Hello @Phorcys can you help me to setup my nginx ?
Phorcys
Phorcys4d ago
@e1k what's the output of curl http://192.168.111.62:9015?
e1k
e1kOP4d ago
I finally found a way around, there is the setting --address it wasn't in the doc but I found it in the source code
Phorcys
Phorcys4d ago
what did you achieve with the address flag? change the port?
Want results from more Discord servers?
Add your server