20260626 サーバ移行03 code-server » 履歴 » バージョン 1
sylow castle, 2026/06/26 19:28
| 1 | 1 | sylow castle | # 20260626 サーバ移行03 code-server |
|---|---|---|---|
| 2 | |||
| 3 | 1. rpmのダウンロード、dnfでのインストール |
||
| 4 | 1. code-serverの起動 |
||
| 5 | 1. パスワード書き換え |
||
| 6 | 1. NGINXの設定 |
||
| 7 | 1. 拡張機能:Language Pack Japaneseのインストールと設定変更 |
||
| 8 | |||
| 9 | ## rpmのダウンロード、dnfでのインストール |
||
| 10 | |||
| 11 | 公式ページ(https://coder.com/docs/code-server/install#fedora-centos-rhel-suse)を読むとrpmが以下からダウンロードできることが分かる |
||
| 12 | https://github.com/coder/code-server/releases |
||
| 13 | |||
| 14 | とりあえずWindowsでダウンロードしてきてscpで転送、rootユーザーのホームディレクトリにmvする |
||
| 15 | |||
| 16 | ``` |
||
| 17 | # dnf install ./<rpmファイル名 |
||
| 18 | ``` |
||
| 19 | |||
| 20 | ## code-serverの起動 |
||
| 21 | |||
| 22 | ついでに自動起動の設定も入れる |
||
| 23 | |||
| 24 | ``` |
||
| 25 | # systemctl enable code-server@$USER |
||
| 26 | # systemctl start code-server@$USER |
||
| 27 | ``` |
||
| 28 | |||
| 29 | ## パスワード書き換え |
||
| 30 | |||
| 31 | $USERのホームディレクトリ配下に.config/code-serverというディレクトリが出来上がっている。 |
||
| 32 | この配下にconfig.yamlというファイルがあるので中を書き換える。 |
||
| 33 | |||
| 34 | ``` |
||
| 35 | bind-addr: 127.0.0.1:28080 |
||
| 36 | auth: password |
||
| 37 | password: <パスワード> |
||
| 38 | cert: false |
||
| 39 | ``` |
||
| 40 | |||
| 41 | ついでにbind-addrのポートをデフォルト(8080)から28080へ切り替えた。 |
||
| 42 | |||
| 43 | ## NGINXの設定 |
||
| 44 | |||
| 45 | https://code.example.com/code/でcode-serverに繋ぎたいとする。 |
||
| 46 | 以下のような設定入れる: |
||
| 47 | httpディレクティブ以下: |
||
| 48 | WebSocketをリバースプロキシするための設定: |
||
| 49 | |||
| 50 | ``` |
||
| 51 | map $http_upgrade $connection_upgrade { |
||
| 52 | default upgrade; |
||
| 53 | '' close; |
||
| 54 | } |
||
| 55 | ``` |
||
| 56 | |||
| 57 | serverディレクティブ以下の設定: |
||
| 58 | |||
| 59 | ``` |
||
| 60 | location ^~ /code/ { |
||
| 61 | proxy_pass http://127.0.0.1:28080/; |
||
| 62 | proxy_cookie_path / /code/; |
||
| 63 | |||
| 64 | proxy_set_header Host $host; |
||
| 65 | proxy_set_header X-Forwarded-Host $host; |
||
| 66 | |||
| 67 | proxy_set_header X-Real-IP $remote_addr; |
||
| 68 | proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; |
||
| 69 | proxy_set_header X-Forwarded-Proto https; |
||
| 70 | |||
| 71 | proxy_http_version 1.1; |
||
| 72 | proxy_set_header Upgrade $http_upgrade; |
||
| 73 | proxy_set_header Connection $connection_upgrade; |
||
| 74 | |||
| 75 | proxy_read_timeout 3600s; |
||
| 76 | proxy_send_timeout 3600s; |
||
| 77 | |||
| 78 | } |
||
| 79 | ``` |
||
| 80 | |||
| 81 | |||
| 82 | ## 拡張機能:Language Pack Japaneseのインストールと設定変更 |
||
| 83 | |||
| 84 | URLにアクセスすると、パスワードを求められるのでさっきのパスワードでログイン |
||
| 85 | |||
| 86 | 画面左メニューよりExtensionsを選び検索。検索ワードは「Japanese」とかで。 |
||
| 87 | Language Pack Japaneseが出てくるのでインストール。 |
||
| 88 | |||
| 89 | > 既定の UI 言語をオーバーライドするには、Configure Display Language コマンドを使用して、VS Code の表示言語を明示的に設定します。 Ctrl+Shift+P を押して "コマンド パレット" を表示し、display と入力して Configure Display Language コマンドをフィルターして表示します。Enter キーを押すと、インストールされている言語の一覧がロケールごとに表示され、現在のロケールが強調表示されます。UI 言語を切り替えるには、別の "ロケール" を選択してください。 |
||
| 90 | |||
| 91 | Code-Server-の場合、Ctrl+Shigt+Pはブラウザのショートカットキーが発動するので、F1を押してコマンドパレットを起動する点だけ注意。 |
||
| 92 | 言語設定を変更するとCode-Serverのリスタート警告が出るのでリスタートする。 |
||
| 93 | |||
| 94 | 終わり。 |