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

网站域名不变网站可以从做吗免费创建论坛网站

网站域名不变网站可以从做吗,免费创建论坛网站,phpstudy如何建设网站,秦皇岛网站制作定制前段时间公司要整合服务器资源#xff0c;刚好趁这次机会将这些乱七八糟的服务器做一次梳理和整合#xff0c;断断续续一个月迁移完成大概优化掉了1/3的机器#xff0c;完成之后遇到了一些问题#xff0c;比如曾今零零散散部署在生产上一些可视化UI#xff1a;apollo… 前段时间公司要整合服务器资源刚好趁这次机会将这些乱七八糟的服务器做一次梳理和整合断断续续一个月迁移完成大概优化掉了1/3的机器完成之后遇到了一些问题比如曾今零零散散部署在生产上一些可视化UIapollokibanagrafana,jenkins 等等要么采用80端口要么对公开放了其他端口为了安全现在不再开放非80之外的公网端口由于机器少了80端口不够这些可视化UI不再能直接访问到了。所以需另寻其他出路。一用nginx做反向代理为了解决这两个问题自然第一反应想到的就是使用反向代理我的理想构思下应该是下图这样的。既用户所有的请求都经过nginx让nginx来判断当前url需要跳转到哪一个后端代理上比较好的策略应该是让nginx来判断当前的host是什么来决定跳转到后端的哪一个webserver上比如a.mip.com 就跳转到apolloj.mip.com 就跳转到jenkins. 以此类推这样就可以完美解决了是吧在nginx中你完全可以使用rewrite模块下if指令来进行判断。二使用if指令这里要提一下nginx比较原始化如果需使用第三方module你还需要重新编译nginx用起来很麻烦所以这里干脆使用OpenResty它扩展了nginx并且集成了很多成熟的lua模块自行下载最新的1.15.8安装方式和nginx一模一样。默认是安装到/usr/local/目录下当你看到有一个openresty目录表示你安装成功。[rootlocalhost local]# lsbin etc games include lib lib64 libexec openresty sbin share src[rootlocalhost local]# pwd/usr/local接下来你可以使用 nginx -v 来看一下openresty版本号啥的。[rootlocalhost sbin]# pwd/usr/local/openresty/nginx/sbin[rootlocalhost sbin]#[rootlocalhost sbin]# ./nginx -vnginx version: openresty/1.15.8.1为了方便我就直接使用nginx开启三个server192.168.23.129:80   nginx上开启的第一个网站就是proxy了。192.168.23.129:8001 nginx上开启的第二个网站模拟apollo。192.168.23.129:8002 nginx上开启的第三个网站,模拟jenkins。1. apollo的模拟server {listen 8001;server_name somename alias another.alias;location / {root html;index apollo.html; } }8001端口网站的默认页是apollo.html这个apollo.html所在路径就是在nginx下的html目录如下所示。[rootlocalhost html]# pwd/usr/local/openresty/nginx/html[rootlocalhost html]# ls50x.html apollo.html index.html jenkins.html2. jenkins的模拟server {listen 8002;server_name somename alias another.alias;location / {root html;index jenkins.html; } }jenkins.html的文件所在路径如上所示哈。不再赘述。3. proxy的模拟server {listen 80;server_name localhost;location / {if ($host a.mip.com) {proxy_pass http://localhost:8001; }if ($host j.mip.com) {proxy_pass http://localhost:8002; } }可以看到只需要使用rewrite模块下的if条件语句通过$host系统变量判断当前的url中的host的值跳转到相应的网站。4. host映射好了接下来只需要将 a.mip.com 和 j.mip.com 映射到nginx的ip地址192.168.23.129即可。因为这些域名方便记忆而不是真实存在的。192.168.23.129 a.mip.com192.168.23.129 j.mip.com5. 启动nginx[rootlocalhost sbin]# ./nginx[rootlocalhost sbin]#[rootlocalhost sbin]#[rootlocalhost sbin]# netstat -tlnpActive Internet connections (only servers)Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program nametcp 0 0 0.0.0.0:8001 0.0.0.0:* LISTEN 3802/nginx: mastertcp 0 0 0.0.0.0:8002 0.0.0.0:* LISTEN 3802/nginx: mastertcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 3802/nginx: mastertcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1172/sshdtcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 1724/mastertcp6 0 0 :::22 :::* LISTEN 1172/sshdtcp6 0 0 ::1:25 :::* LISTEN 1724/master通过上图可以看到8080018002 端口都已经开启了接下来大家可以到浏览器去验证一下了。可以看到这个问题已经很完美的解决了好了这就是本篇和大家聊到的实际场景中遇到的一个问题希望本篇对你有帮助以下是全部的nginx.conf。#user nobody;worker_processes 1;#error_log logs/error.log;#error_log logs/error.log notice;#error_log logs/error.log info;#pid logs/nginx.pid;events {worker_connections 1024;}http {include mime.types;default_type application/octet-stream;log_format main $host ---- $remote_addr - $remote_user [$time_local] $request $status $body_bytes_sent $http_referer $http_user_agent $http_x_forwarded_for;access_log logs/access.log main;sendfile on;#tcp_nopush on;#keepalive_timeout 0;keepalive_timeout 65;#gzip on;server {listen 80;server_name localhost;#charset koi8-r;#access_log logs/host.access.log main;# location /get {# set_unescape_uri $key $arg_key; # this requires ngx_set_misc# redis2_query get $key;# redis2_pass 10.105.13.174:6379;# }location / {if ($host a.mip.com) {proxy_pass http://localhost:8001; }if ($host j.mip.com) {proxy_pass http://localhost:8002; }root html;index index.html index.htm; }#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;#} }# another virtual host using mix of IP-, name-, and port-based configuration#server {listen 8001;server_name somename alias another.alias;location / {root html;index apollo.html; } }server {listen 8002;server_name somename alias another.alias;location / {root html;index jenkins.html; } }# HTTPS server##server {# listen 443 ssl;# server_name localhost;# ssl_certificate cert.pem;# ssl_certificate_key cert.key;# ssl_session_cache shared:SSL:1m;# ssl_session_timeout 5m;# ssl_ciphers HIGH:!aNULL:!MD5;# ssl_prefer_server_ciphers on;# location / {# root html;# index index.html index.htm;# }#}}
http://www.yutouwan.com/news/347502/

相关文章:

  • 那种网站打不开做摄影网站的目的是什么意思
  • 微信网站作用wordpress百度主动不推送了
  • 装修网站免费设计搜索引擎案例分析结论
  • 建设局工程网站知名企业名字
  • 申请免费个人网站和域名余姚做网站设计的公司
  • 网站建设招聘济南网站建设成之运维
  • 做液氮冰淇淋店网站wordpress 自定义 sql
  • 哈尔滨 房产网站建设企业策划工作内容
  • 域名怎么绑定网站wordpress 多用户插件
  • 各大网站收录dede怎么设置wap网站
  • 手机网站制作费用微信网站制作企业
  • 多语言网站系统专业做物业网站的公司吗
  • 大连网站制作姚喜运查看网站的目录文件夹权限设置
  • 吉林电商网站建设价格东莞++网站建设
  • 哪个网站可以代做软件杭州手机建设网站
  • 南京高新区网站建设能源网站模板
  • 深圳知名网站建设价格南宁智慧人社app官方下载
  • 网站设计开题报告范文大宗商品电子交易平台
  • 怎么制作网站店铺网站建设的分类
  • 想要黑掉一个网站 要怎么做html5移动端网站建设
  • xv10相同网站北京广告公司工资
  • wordpress 多语言建站为什么输入网址打开的却是别的网站
  • 松原公司做网站的流程wordpress宝塔伪静态
  • 使用word做网站网站这么上百度
  • 网站建设软著百度上搜不到网站
  • 集团网站设计建设做英文兼职的网站
  • 大连做网站 选领超科技宁波网站建设哪里有
  • 厦门汽车充电站建设报备网站wordpress博客栏目设计
  • 阿里巴巴的网站二维码怎么做域名注册网站哪个好
  • 青岛在线制作网站忻州企业网站建设