# Sunucuya Code Service (VS Code) Kurulumu

## 🔧 1. Gerekli Güncellemeleri Yap

```bash
sudo apt update && sudo apt upgrade -y
```

## 🌐 2. Gerekli Paketleri Yükle

```bash
sudo apt install curl wget gnupg -y
```

---

## 📦 3. Code Server'ı İndir ve Kur

Code Server'ın en son sürümünü indirip kurmak için:

```bash
curl -fsSL https://code-server.dev/install.sh | sh
```

Kurulumdan sonra `code-server` komutu aktif olacaktır.

---

## ⚙️ 4. Varsayılan Yapılandırmayı Yap

Config dosyası:

```bash
~/.config/code-server/config.yaml
```

Örnek yapı:

```yaml
bind-addr: 127.0.0.1:8080
auth: password
password: kendi-güçlü-şifren
cert: false
```

> `bind-addr`'ı `0.0.0.0:8080` yaparsan dışarıdan doğrudan erişebilirsin ama güvenlik risklidir. Biz güvenli bağlantı için nginx kullanacağız.

---

## 🚀 5. Systemd Servisi ile Başlat

```bash
sudo nano /etc/systemd/system/code-server.service
```

İçeriği:

```bash
[Unit]
Description=code-server
After=network.target

[Service]
Type=simple
User=berk
ExecStart=/usr/bin/code-server
Restart=on-failure

[Install]
WantedBy=default.target
```

Etkinleştir ve başlat:

```bash
sudo systemctl daemon-reexec
sudo systemctl daemon-reload
sudo systemctl enable --now code-server
```

---

## 🌍 6. NGINX ile Güvenli Yayın (örnek: [`code.iberk.me`](http://code.iberk.me))

### SSL ile yayın için örnek `nginx` konfigürasyonu:

```bash
sudo nano /etc/nginx/sites-available/vscode.example.com
```

```nginx
server {
    listen 80;
    server_name vscode.example.com;

    location / {
        proxy_pass http://127.0.0.1:8080/;
        proxy_set_header Host $host;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection upgrade;
        proxy_set_header Accept-Encoding gzip;
        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;
    }
}
```

```bash
sudo ln -s /etc/nginx/sites-available/vscode.example.com /etc/nginx/sites-enabled/
sudo nginx -t && sudo systemctl restart nginx
```

---

## 🔐 7. SSL Sertifikası Al (Let's Encrypt)

```bash
sudo apt install certbot python3-certbot-nginx -y
sudo certbot --nginx -d vscode.example.com
```

---

## ✅ 8. Test

Tarayıcında şu adrese git:

```bash
https://vscode.example.com
```

ve belirlediğin şifre ile giriş yap.

---

Hazır olduğunda bir sonraki adım olarak **uzaktan klasör erişimi**, **uzantı yükleme**, veya **Git entegrasyonu** gibi işlemleri yapabiliriz. Yardımcı olayım mı?
