我之所以来到这里,是因为正如标题所示,我安装了代码服务器,只是我希望它在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你能帮我吗?我正在设法找到解决这个问题的办法,但我不知道怎么做
发布于 2021-11-06 09:31:42
最后,我找到了解决问题的方法,我不得不使用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>
发布于 2021-11-05 22:58:54
我认为以下几点应该有效:
<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 />
</VirtualHost>启用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 />
</VirtualHost>https://stackoverflow.com/questions/69859920
复制相似问题