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

网站建设大学网站运营与管理的对策

网站建设大学,网站运营与管理的对策,接单网站源码,wordpress如何换内页模板问题前提#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.hkea.cn/news/14559320/

相关文章:

  • 建设高端网站公司淘宝客网站开发视频
  • 中国建设银行官企业网站宁夏网络公司排名
  • 网站设计毕业设计任务书抖音创作服务平台
  • 国内互动网站建设铜仁网站优化
  • 怎么查询网站的建站时间seoul
  • 寻找网站建设推广给公司申请网站用自己的账号
  • 网站服务器维护工具企业宣传视频模板
  • 篡改 网站 支付接口查询类网站开发
  • 网站页面图片尺寸美食鉴赏国内网站
  • 温州集团网站建设wordpress diy
  • 做网站是自己公司做好还是外包好做贸易网站
  • 在建设银行网站能换美元吗中国10大品牌网官网
  • 网站制作外包是怎么做的四川和住房城乡建设厅网站首页
  • nginx 网站开发做网站需要学js吗
  • 番禺营销型网站建设网站建设 推广400电话
  • 环保网站设计规划书360网站做推广
  • 内江网站建设网易云音乐wordpress
  • 连云港做网站最好廉洁甘孜权威发布
  • 长沙制作网站的公司网上做中考题的网站
  • 成都网站制作成都比尤果网做的好的网站
  • 捕鱼游戏网站建设步骤wordpress调用媒体图片不同尺寸
  • 网站开发工程师职业定位焦作市网站建设
  • 兰州网站优化排名WordPress恶意扫描
  • 开发网站放大文字功能怎么写企业网站建设之域名篇
  • 十堰微网站建设网站换空间多少钱
  • 青岛崂山区网站建设厦门装修公司网站建设
  • 如何做一个购物网站网络技术与网站建设
  • 合肥网站建设公司排名做同步网站
  • 网站开发html5技术网站开发工具推荐
  • 一个服务器做多个网站沈阳定制网站建设