我來這里,因為正如標題所示,我安裝了代碼服務器,但我希望它在 apache2 下而不是在 nginx 下。我正在嘗試在 https 下設定我的服務器,我已經有了我的證書,我只需要組態檔。我是初學者,所以我不了解有關 nginx 和代碼服務器如何作業以及如何適應它的所有內容。我按照很多教程來做到這一點,組態檔總是一樣的:
server {
listen 80;
listen [::]:80;
server_name domainname.domain.dev;
location / {
proxy_pass http://localhost:8080/;
proxy_set_header Host $host;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection upgrade;
proxy_set_header Accept-Encoding gzip;
}
}
在我必須設定服務檔案之前:code-server.service:
[Unit]
Description=code-server
After=apache2.service #I changed this line before it was: nginx.service
[Service]
Type=simple
Environment=PASSWORD=code-server-password
ExecStart=/usr/bin/code-server --bind-addr 127.0.0.1:8080 --user-data-dir /var/lib/code-server --auth password
Restart=always
[Install]
WantedBy=multi-user.target
你能幫助我嗎 ?我正在嘗試找到解決此問題的方法,但我不知道該怎么做
uj5u.com熱心網友回復:
我相信以下應該有效:
<VirtualHost _default_:80>
ServerName myserverdomainname
ServerAdmin webmaster@myserverdomainname
ProxyRequests Off
ProxyPreserveHost On
ProxyPass / http://localhost:8080/
ProxyPassReverse / http://localhost:8080/
RequestHeader set Connection ""
RequestHeader set Upgrade $http_upgrade;
RequestHeader set Connection "upgrade"
RequestHeader set X-Forwarded-Proto "http"
<Location />
啟用 SSL
<VirtualHost _default_:443>
ServerName myserverdomainname
ServerAdmin webmaster@myserverdomainname
SSLEngine on
SSLProxyEngine on
##LE Certs
SSLCertificateFile /etc/letsencrypt/live/domain/cert.pem
SSLCertificateKeyFile /etc/letsencrypt/live/domain/privkey.pem
SSLCertificateChainFile /etc/letsencrypt/live/domain/fullchain.pem
ProxyRequests Off
ProxyPreserveHost On
ProxyPass / http://localhost:8000/
ProxyPassReverse / http://localhost:8000/
RequestHeader set Connection ""
RequestHeader set Upgrade $http_upgrade;
RequestHeader set Connection "upgrade"
RequestHeader set X-Forwarded-Proto "https"
<Location />
uj5u.com熱心網友回復:
所以最后我找到了我的問題的解決方案,我不得不使用 apache 反向代理。我不明白所有的代碼,但它有效。對于那些和我有同樣問題的人,我找到了這個網站:https : //toscode.gitee.com/crazyleega/code-server/blob/master/doc/quickstart.md
為了激活 https 并因此激活 ssl,我這樣做了:
<VirtualHost *:443>
ServerName domainname
RewriteEngine On
RewriteCond %{HTTP:Upgrade} =websocket [NC]
RewriteRule /(.*) ws://localhost:8080/$1 [P,L]
RewriteCond %{HTTP:Upgrade} !=websocket [NC]
RewriteRule /(.*) http://localhost:8080/$1 [P,L]
SSLEngine on
SSLProxyEngine on
SSLCertificateFile pathofyourcert
SSLCertificateKeyFile pathofyourkey
ProxyRequests off
ProxyPass / http://localhost:8080/ nocanon
ProxyPassReverse / http://localhost:8080/
</VirtualHost>
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/350511.html
