LOLINTERNETZ / vscodeoffline

Enables Visual Studio Code's extension gallery to be used in offline (air-gapped) environments. Or, run your own gallery!
https://hub.docker.com/u/lolinternet
MIT License
95 stars 28 forks source link

Add NGINX Configuration #62

Open alirezasafi opened 4 months ago

alirezasafi commented 4 months ago

hi! I've been exploring your project and noticed that it currently doesn't include an NGINX configuration. I suggest adding an NGINX configuration files to the repository. nginx.conf

events {}
http {
    server {
        listen 80;
        server_name update.code.visualstudio.com az764295.vo.msecnd.net marketplace.visualstudio.com;

        return 301 https://vscgallery:443;
    }

    server {
        listen 443 ssl;
        server_name update.code.visualstudio.com az764295.vo.msecnd.net marketplace.visualstudio.com;

        ssl_certificate /etc/nginx/ssl/vscode.crt;
        ssl_certificate_key /etc/nginx/ssl/vscode.key;

        location / {
            proxy_pass https://vscgallery:443;
            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_set_header X-Forwarded-Proto $scheme;
        }
    }
}

docker-compoe.yaml

version: '3'
services:

  vscsync:
    image: lolinternet/vscsync:latest
    build:
      context: ./
      dockerfile: ./vscoffline/vscsync/Dockerfile
    dns:
      - 1.1.1.1
    volumes:
      # Enable for dev
      #- ./vscoffline/:/opt/vscoffline/:ro
      - ./artifacts/:/artifacts/
    environment:
      - SYNCARGS=--sync
      # Enable to sync all extensions
      #- SYNCARGS=--syncall
      # Enable a logfile
      #- SYNCARGS=--sync --logfile /logs/sync.log

  vscgallery:
    image: lolinternet/vscgallery:latest
    build:
      context: ./
      dockerfile: ./vscoffline/vscgallery/Dockerfile
    volumes:
      # Enable for dev
      #- ./vscoffline/:/opt/vscoffline/:ro
      - ./artifacts/:/artifacts/
      # Enable for custom SSL certs
      #- ./vscoffline/vscgallery/ssl/:/opt/vscoffline/vscgallery/ssl # Enable for custom SSL certs
      # Enable to store logfiles in its own folder
      # ./logs/:/logs/
    # ports:
    #   - 443:443
    environment:
      - BIND=0.0.0.0:443

  nginx:
    image:
      nginx:latest
    volumes:
      - ./nginx.conf:/etc/nginx/nginx.conf:ro
      - ./ssl/:/etc/nginx/ssl/:ro
    ports:
      - 80:80
      - 443:443

Thank you for considering my suggestion.

LOLINTERNETZ commented 2 months ago

Thanks @alirezasafi for your suggestion. I'm leaning toward not adding this at the moment, primarily to reduce indirection complexity. I also suspect most environments will either use the vscgallery http host directly or have many layers of Kubernetes.