我已将nginx配置为在“ / vscode”,“ / jupyterlab”,“ / eclipse”等网址上运行多个Web服务器。
我尝试了以下配置,其中8080端口上的VSCode Web服务器正在运行。我观察到的输出是“ https:///”可以正常工作并显示vscode UI,但是“ https:/// vscode”给出了404 not found错误。
下面是我的配置文件:
user www-data;
worker_processes auto;
pid /run/nginx.pid;
events {
worker_connections 768;
# multi_accept on;
}
http {
server
{
listen 443 ssl;
listen [::]:443 ssl;
ssl_certificate /etc/ssl/certs/cert.pem; # managed by Certbot
ssl_certificate_key /etc/ssl/certs/cert.key; # managed by Certbot
location ~* "^/port/(\d+)/(.*)$"
{
add_header Access-Control-Allow-Origin *;
proxy_pass http://127.0.0.1:$1/$2$is_args$args;
include /etc/nginx/proxy_params;
}
location /vscode/
{
add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range';
add_header Access-Control-Allow-Origin *;
proxy_pass http://localhost:8080;
include /etc/nginx/proxy_params;
}
location /mlflow
{
add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range';
add_header Access-Control-Allow-Origin *;
proxy_pass http://127.0.0.1:5000;
include /etc/nginx/proxy_params;
}
location /
{
add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range';
add_header Access-Control-Allow-Origin *;
proxy_pass http://localhost:8080;
include /etc/nginx/proxy_params;
}
}