Nginx 嵌套在React网站中的VueJs网站

Nginx 嵌套在React网站中的VueJs网站,nginx,web-hosting,nginx-reverse-proxy,Nginx,Web Hosting,Nginx Reverse Proxy,你好, 我知道这是个奇怪的问题:D 我在domain.io上主持一个由React支持的网站 我在portfolio.domain.io 我正在尝试配置nginx,以便:domain.io/portfolio显示portfolio.domain.io 我尝试了很多事情,比如代理传递或重定向,但似乎我做错了 目前我的配置中有: location = /portfolio { rewrite ^ https://portfolio.domain.io$request_uri permanent;

你好,

我知道这是个奇怪的问题:D

我在
domain.io上主持一个由React支持的网站

我在
portfolio.domain.io

我正在尝试配置nginx,以便:
domain.io/portfolio
显示
portfolio.domain.io

我尝试了很多事情,比如代理传递或重定向,但似乎我做错了

目前我的配置中有:

location = /portfolio {
  rewrite ^ https://portfolio.domain.io$request_uri permanent;
}
还尝试:

  location /portfolio {
    proxy_pass  https://portfolio.domain.io$request_uri;
    proxy_set_header Host  portfolio.domain.io;
  }
你知道我可以尝试什么吗?或者这可能吗

谢谢

编辑:(完整配置)

```


```我认为这不是你想要的答案,但它可能会奏效。我以前有一个技巧,但这需要两个域都有一个有效的SSL证书

诀窍是让iframe占据100%的视图,它的行为就像一个单页应用程序。(我想这就是它背后的原因)

html,body,div,span,applet,object,iframe,
h1、h2、h3、h4、h5、h6、p、块报价、预,
a、 缩写,首字母缩写,地址,大,引用,代码,
del、dfn、em、img、ins、kbd、q、s、samp、,
小、走向、强、次、辅助、tt、var、,
b、 u,i,中心,
dl,dt,dd,ol,ul,li,
字段集、表单、标签、图例、,
表格、标题、正文、tfoot、THAD、tr、th、td、,
文章、旁白、画布、细节、嵌入、,
图,figcaption,页脚,页眉,H组,
菜单、导航、输出、ruby、节、摘要、,
时间、标记、音频、视频{
保证金:0;
填充:0;
边界:0;
字体大小:100%;
字体:继承;
垂直对齐:基线;
}
身体{
高度:100vh;
宽度:100vw;
溢出:隐藏;
}
iframe{
身高:100%;
宽度:100%;
溢出:隐藏;
}

你的头衔

您能否提供整个服务器指令,以便更好地了解哪些内容未正确设置?顺便说一句,您还需要*.domain.com的通配符SSL证书。如果您只有一个域SSL证书,它将无法工作。我已经为domain.io和portfolio.domain.io创建了一个证书,这还不够吗?(我还在主帖子中添加了完整的配置)嗨,谢谢你的回答,但这不是项目的目标。我开始这个项目是为了学习nginx的工作原理;)
server {

        root /var/www/ivan/website/dist;
        index index.html index.php ndex.htm index.nginx-debian.html;

        server_name domain.io _;


    location = /portfolio {
            rewrite ^ https://portfolio.domain.io$request_uri permanent;            
    }

        location / {
                try_files $uri $uri/ =404;
        }

        location ~ /\.ht {
                deny all;
        }

        location ~*  \.(jpg|jpeg|png|gif|ico|css|js)$ {
            expires 15d;
        }

        location ~*  \.(pdf)$ {
            expires 30d;
        }
        listen [::]:443 ssl http2; 
    listen 443 ssl http2; 
        ssl_certificate /etc/letsencrypt/live/domain.io/fullchain.pem; # managed by Certbot
        ssl_certificate_key /etc/letsencrypt/live/domain.io/privkey.pem; # managed by Certbot
        include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
        ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
}
server {
    if ($host = domain.io) {
        return 301 https://$host$request_uri;
    } # managed by Certbot

    server_name domain.io _;
    return 404; # managed by Certbot
}