当前位置: 首页 > news >正文

网站运营与管理的对策淘宝联盟 做网站

网站运营与管理的对策,淘宝联盟 做网站,怎样做二维码网站,商城网站建设市场分析论文问题前提#xff1a;目前我的项目是已经搭建了网关根据访问路径路由到微服务#xff0c;然后现在我使用了Nginx将静态资源都放在了Nginx中#xff0c;然后我后端定义了一个接口访问一个html页面#xff0c;但是html页面要用到静态资源#xff0c;这个静态资源在我的后端是…问题前提目前我的项目是已经搭建了网关根据访问路径路由到微服务然后现在我使用了Nginx将静态资源都放在了Nginx中然后我后端定义了一个接口访问一个html页面但是html页面要用到静态资源这个静态资源在我的后端是没有的静态资源都在Nginx中那么我要怎么办呢其中一个好办法就是使用Nginx访问我们后台网关然后后台网关直接访问我们的微服务因为都在一个域名下面因此直接静态资源就能访问到这里后面会详细解释。 前置条件的配置 Nginx 配置 可以看到在域名www.51xuecheng.cn localhost;下面访问我们的静态资源路径就会通过alias映射到我们服务器上指定目录下面的文件。也就相当于我们的静态资源部署到Nginx中我记着之前学过可以将静态资源直接放到Nginx中的什么目录下就不用使用alias了 #访问minio文件系统的网址     upstream fileserver{     server 192.168.101.65:9000 weight10;     }      server {         listen       80;         server_name  www.51xuecheng.cn localhost;         #rewrite ^(.*) https://$server_name$1 permanent;         #charset koi8-r;         ssi on;         ssi_silent_errors on;         #access_log  logs/host.access.log  main;         location / {             alias   E:/code/xc-ui-pc-static-portal/;             index  index.html index.htm;         }         #静态资源         location /static/img/ {                   alias  E:/code/xc-ui-pc-static-portal/img/;         }          location /static/css/ {                   alias   E:/code/xc-ui-pc-static-portal/css/;         }          location /static/js/ {                   alias   E:/code/xc-ui-pc-static-portal/js/;         }          location /static/plugins/ {                   alias   E:/code/xc-ui-pc-static-portal/plugins/;                 add_header Access-Control-Allow-Origin http://ucenter.51xuecheng.cn;                   add_header Access-Control-Allow-Credentials true;                   add_header Access-Control-Allow-Methods GET;         }          location /plugins/ {                   alias   E:/code/xc-ui-pc-static-portal/plugins/;         }          location /course/preview/learning.html {                 alias E:/code/xc-ui-pc-static-portal/course/learning.html;         }          location /course/search.html {                   root   E:/code/xc-ui-pc-static-portal;         }          location /course/learning.html {                   root   E:/code/xc-ui-pc-static-portal;         }          #error_page  404              /404.html;         # redirect server error pages to the static page /50x.html         #         error_page   500 502 503 504  /50x.html;         location /50x.html {             root   html;         }         # proxy the PHP scripts to Apache listening on 127.0.0.1:80         #         #location ~ \.php$ {         #    proxy_pass   http://127.0.0.1;         #}         # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000         #         #location ~ \.php$ {         #    root           html;         #    fastcgi_pass   127.0.0.1:9000;         #    fastcgi_index  index.php;         #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;         #    include        fastcgi_params;         #}         # deny access to .htaccess files, if Apaches document root         # concurs with nginxs one         #         #location ~ /\.ht {         #    deny  all;         #}     }     server {         listen       80;         server_name  file.51xuecheng.cn;         #charset koi8-r;         ssi on;         ssi_silent_errors on;         #access_log  logs/host.access.log  main;         location /video {             proxy_pass   http://fileserver;         }         location /mediafiles {             proxy_pass   http://fileserver;         }    } 网关配置 spring:cloud:gateway: # filter: # strip-prefix: # enabled: trueroutes: # 网关路由配置- id: content-api # 路由id自定义只要唯一即可# uri: http://127.0.0.1:8081 # 路由的目标地址 http就是固定地址uri: lb://content-api # 路由的目标地址 lb就是负载均衡后面跟服务名称predicates: # 路由断言也就是判断请求是否符合路由规则的条件- Path/content/** # 这个是按照路径匹配只要以/content/开头就符合要求 # filters: # - StripPrefix1- id: system-api# uri: http://127.0.0.1:8081uri: lb://system-apipredicates:- Path/system/** # filters: # - StripPrefix1- id: media-api# uri: http://127.0.0.1:8081uri: lb://media-apipredicates:- Path/media/** # filters: # - StripPrefix1- id: search-service# uri: http://127.0.0.1:8081uri: lb://searchpredicates:- Path/search/** # filters: # - StripPrefix1- id: auth-service# uri: http://127.0.0.1:8081uri: lb://auth-servicepredicates:- Path/auth/** # filters: # - StripPrefix1- id: checkcode# uri: http://127.0.0.1:8081uri: lb://checkcodepredicates:- Path/checkcode/** # filters: # - StripPrefix1- id: learning-api# uri: http://127.0.0.1:8081uri: lb://learning-apipredicates:- Path/learning/** # filters: # - StripPrefix1- id: orders-api# uri: http://127.0.0.1:8081uri: lb://orders-apipredicates:- Path/orders/** # filters: # - StripPrefix1 后端接口代码 /**  * description 课程预览发布  * author Mr.M  * date 2022/9/16 14:48  * version 1.0  */  Controller public class CoursePublishController {  GetMapping(/coursepreview/{courseId})  public ModelAndView preview(PathVariable(courseId) Long courseId){       ModelAndView modelAndView new ModelAndView();       modelAndView.addObject(model,null);       modelAndView.setViewName(course_template);    return modelAndView;   } } 我们的test.ftl应该是course_template 但是我们接口虽然访问了这个ftl文件但是文件中的资源引用确不能访问到因为我们resource下面没有其他静态文件了。 可以看到我们course_template文件中的静态文件路径为/static/plugin等 如果我们使用网址http://localhost:63040/content/coursepreview/74 那么就会从我们的域名 http://localhost::63040下面的classpath也就是我们的resource路径下面找但是这个路径下面并没有这些个文件因此找不到。 问题解决 使用Nginx访问我们的网关然后再通过网关路由到我们的微服务然后我们静态页面中的资源就会到我们的Nginx相应的域名下面去找。代码如下 #后台网关   upstream gatewayserver{     server 127.0.0.1:63010 weight10;   }   server {         listen       80;         server_name  www.51xuecheng.cn localhost;         #rewrite ^(.*) https://$server_name$1 permanent;         #charset koi8-r;         ssi on;         ssi_silent_errors on;         #access_log  logs/host.access.log  main;         location / {             alias   E:/code/xc-ui-pc-static-portal/;             index  index.html index.htm;         }         #静态资源         location /static/img/ {                   alias  E:/code/xc-ui-pc-static-portal/img/;         }          location /static/css/ {                   alias   E:/code/xc-ui-pc-static-portal/css/;         }          location /static/js/ {                   alias   E:/code/xc-ui-pc-static-portal/js/;         }          location /static/plugins/ {                   alias   E:/code/xc-ui-pc-static-portal/plugins/;                 add_header Access-Control-Allow-Origin http://ucenter.51xuecheng.cn;                   add_header Access-Control-Allow-Credentials true;                   add_header Access-Control-Allow-Methods GET;         }          location /plugins/ {                   alias   E:/code/xc-ui-pc-static-portal/plugins/;         }          location /course/preview/learning.html {                 alias E:/code/xc-ui-pc-static-portal/course/learning.html;         }          location /course/search.html {                   root   E:/code/xc-ui-pc-static-portal;         }          location /course/learning.html {                   root   E:/code/xc-ui-pc-static-portal;         }          error_page   500 502 503 504  /50x.html;         location /50x.html {             root   html;         }        }     }         #api         location /api/ {                 proxy_pass http://gatewayserver/;         } 下面是我在研究这个问题时候的一些疑问gpt的解答可能有一些不太准确但结果是通的
http://www.dnsts.com.cn/news/201246.html

相关文章:

  • 公司做网站一定要钱吗网络关键词
  • 黄岐建网站网站无障碍建设报告
  • 医药网站建设中图片wordpress视频模块
  • 建设信用卡银行积分商城网站公司域名备案网站名称
  • 计算机网站开发项目深圳4a广告公司有哪些
  • cnnic网站洛阳400电话洛阳网站seo
  • 雄安建站服务书画院网站建设
  • 百度网站入口贵州门户网站建设
  • 肇庆东莞网站建设郑州哪个医院看妇科病最好的医院
  • 网站开发常用图标企业查询软件排行榜
  • 云网站制作的流程图淘宝权重查询
  • 购物网站建设投资预算网站的引导页面是什么意思
  • wordpress全站pjax搬瓦工搭建wordpress
  • 网站后台欢迎界面印刷行业网站建设
  • 情人做网站海门住房和城乡建设局网站
  • 手机网站吧做网站后台服务器什么最好
  • 长尾关键词爱站凡科互动游戏作弊软件
  • 做网站开发人员架构中企动力 网站报价
  • html5模板网站上海网架公司
  • WordPress网站转HTPPSwordpress ftp 端口
  • 安徽省建设厅证书查询官方网站石家庄网站建设wsjz
  • 自己可以建网站吗wordpress 页面id
  • 定南网站建设qq wordpress登陆
  • 西安网站设计制作多少钱高中男女做那个视频网站
  • 加强网站内容建设创新培训机构网站源码
  • 中英文网站怎么做国家企业信用公示(上海)
  • 网络服务提供者不履行法律行政法规规定的人才网站的seo怎么做
  • 天空台108网站找手工活带回家做红色系列的网站
  • 河南单位网站建设如何推广自己产品
  • 竟标网站源码天津做网页设计的公司