Code Monkey home page Code Monkey logo

Comments (5)

helloxz avatar helloxz commented on May 25, 2024

请参考帮助文档的配置进行反向代理,若还有疑问,请贴出反向代理的配置内容,谢谢。

from onenav.

MinChoul0 avatar MinChoul0 commented on May 25, 2024

请参考帮助文档的配置进行反向代理,若还有疑问,请贴出反向代理的配置内容,谢谢。

就是参考帮助文档配置的,我还怀疑是不是因为https重定向到http导致的

from onenav.

helloxz avatar helloxz commented on May 25, 2024

请直接提供您的Nginx的配置文件部分,不然不好判断问题。

from onenav.

MinChoul0 avatar MinChoul0 commented on May 25, 2024

大概知道原因了,还是nginx配置;
需求背景是:访问a服务器部署的A域名,想默认转到b服务器的oneav服务B域名 ;
服务器a上用nginx配置:
`server
{
listen 80;
listen 443 ssl http2;
server_name a.com;
index index.php index.html index.htm default.php default.htm default.html;
root /www/wwwroot/a.com;
charset utf-8,gbk;

#SSL-START SSL相关配置,请勿删除或修改下一行带注释的404规则
#error_page 404/404.html;
ssl_certificate    /www/fullchain.pem;
ssl_certificate_key    /www/privkey.pem;
ssl_protocols TLSv1.1 TLSv1.2 TLSv1.3;
ssl_ciphers EECDH+CHACHA20:EExxxxxraft:EECDxxxxx+3DES:!MD5;
ssl_prefer_server_ciphers on;
ssl_session_cache shared:SSL:10m;
ssl_session_timeout 10m;
add_header Strict-Transport-Security "max-age=31536000";
error_page 497  https://$host$request_uri;


#ERROR-PAGE-START  错误页配置,可以注释、删除或修改
#    #error_page 502 /502.html;
#ERROR-PAGE-END

#PHP-INFO-START  PHP引用配置,可以注释或修改
include enable-php-00.conf;
#PHP-INFO-END

#REWRITE-START URL重写规则引用,修改后将导致面板设置的伪静态规则失效
include /www/server/panel/vhost/rewrite/a.conf;
#REWRITE-END

#禁止访问的文件或目录
location ~ ^/(\.user.ini|\.htaccess|\.git|\.svn|\.project|LICENSE|README.md)
{
    return 404;
}

#一键申请SSL证书验证目录相关设置
location ~ \.well-known{
    allow all;
}


    location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
    expires      30d;
    error_log /dev/null;
    access_log /dev/null;
    proxy_pass https://127.0.0.1:23901;

}

    location ~ .*\.(js|css)?$
{
    expires      12h;
    error_log /dev/null;
    access_log /dev/null;
    proxy_pass https://127.0.0.1:23901;

}
    #想默认转到b域名的oneav服务
	  location / {
    proxy_connect_timeout 10;
   	  proxy_http_version 1.1;
   	  proxy_set_header Connection "";
    proxy_set_header Host $host;
    #proxy_pass http://b.com:8888/;
    return 301 http://b.com:8888$request_uri;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    #try_files $uri $uri/ @router;
}
#本机其他服务,端口23901
    location /mmm/    {
    proxy_pass https://127.0.0.1:23901;
    proxy_redirect off;
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "upgrade";
    proxy_set_header Host $http_host;
    proxy_read_timeout 300s;
}

access_log  /www/wwwlogs/a.log;
error_log  /www/wwwlogs/a.log;

}
`
部分原因:
重点就是默认的 location / {}下配置,用proxy_pass方式,全部的布局文件啥的,如css,js等其实是404的(浏览器F12看了下),改了几次都不清楚咋代理过来,后面临时用 return 301的方式直接指过去就没这个问题了。
如下:
#proxy_pass http://b.com:8888/; ----ccs,js 直接404
return 301 http://b.com:8888$request_uri; ---直接301重定向可以访问通

from onenav.

helloxz avatar helloxz commented on May 25, 2024

你多个服务弄到一个nginx server下,维护和可读性比较差,而且容易冲突。我看你用的二级目录来反代OneNav,猜测是反代后静态资源依然是从顶级目录开始,然后css/js你又是反代的其它服务,导致静态资源404,你说的301或者用subs_filter替换应该都可以解决。

from onenav.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.