const{createApp}=Vue const{createVuetify,useGoTo,useDisplay}=Vuetify var data={alert:{show:false,color:'success',text:'',timeout:0,},theme:{dark:false,},nav:{showDrawer:false,showTOC:true,tocPanel:0,tab:'account',post:{discussionId:6255,currentPage:1,targetPage:1,total:17,anchor:0,goToOptions:{container:null,duration:0,easing:'easeInOutCubic',offset:-100,},worker:null,task:[],active:[],apiLock:[],originLike:new Map([]),},related:{block:1,}},search:{width:80,text:null,loading:false,},tags:[{id:21,url:'/t/182c700e6a045c756177250e2d18',name:'Nginx',color:'#66BB6A',icon:'mdi-tag-heart',},],posts:[{id:73898,num:0,uid:13653,content:'\u003Cp\u003E先叠甲: 我是业余运维.\u003C/p\u003E\u003Cp\u003E昨天, 在宝塔上对线上服务 A 修改 proxy_pass, 端口从 7511 改成 7501:\u003C/p\u003E\u003Ccode\u003Elocation / { proxy_pass http://localhost:7501; }\u003C/code\u003E\u003Cp\u003E更新配置后, 错误日志显示 upstream 依旧是 127.0.0.1:7511, 询问 AI, 反复折腾后, 依旧没能解决. 但在此期间, 没有任何报错, 包括在宝塔上保存配置, 在服务器上 nginx -t, nginx -s reload, nginx -T 等.\u003C/p\u003E\u003Cp\u003E推测配置被缓存了, 但为什么被缓存, 不清楚. 只能先重启 nginx 把服务搞上线. \u003C/p\u003E\u003Cp\u003E重启之前就隐隐觉得这次重启肯定不顺利, 毕竟 nginx -s reload 没有生效, 有些地方肯定有问题. 果然报错: 7503 端口被占用, nginx 无法启动. \u003C/p\u003E\u003Cp\u003E我瞬间就慌了, 在做了两次无效重复后, 理智回来了: nginx -T 查出 7503 在服务 B 的配置文件, 果断注释那一行然后成功启动 nginx, 线上服务恢复, 服务 A 也正常了.\u003C/p\u003E\u003Cp\u003E7503 端口本身就被一个 next.js 项目占用, 但不知道为什么还要写到 nginx 配置文件, 只能认为不会 nginx. 问了前端负责人, 到现在也没回我~~\u003C/p\u003E\u003Cp\u003Enginx version: nginx/1.20.2\u003C/p\u003E',ipRegion:'',updatedByUid:0,createdAt:'2025-03-21 16:11:50',updatedAt:'2025-03-24 23:57:02',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:73899,num:1,uid:1008,content:'nginx -t \u0026amp;\u0026amp; nginx -s reload',ipRegion:'',updatedByUid:0,createdAt:'2025-03-21 16:47:40',updatedAt:'2025-03-24 23:57:02',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:73900,num:2,uid:38,content:'-t 只是測試配置文件。又不能檢測端口已占用!',ipRegion:'',updatedByUid:0,createdAt:'2025-03-21 16:57:18',updatedAt:'2025-03-24 23:57:02',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:73901,num:3,uid:63,content:'reload 并不会重新 listen\u003Cbr\u003E我觉得你还是先仔细检查一下再说',ipRegion:'',updatedByUid:0,createdAt:'2025-03-21 17:23:59',updatedAt:'2025-03-24 23:57:02',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:73902,num:4,uid:63,content:'哦。明白了\u003Cbr\u003E你是期望-t 失败或者-s reload 失败?',ipRegion:'',updatedByUid:0,createdAt:'2025-03-21 17:25:32',updatedAt:'2025-03-24 23:57:02',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:73903,num:5,uid:13653,content:'是的, 如果 -t 或 reload 失败那就可以查到错误. 但 -t 并没有. \u003Cbr\u003Elisten 7503 这条配置我事先并不知情',ipRegion:'',updatedByUid:0,createdAt:'2025-03-21 17:35:40',updatedAt:'2025-03-24 23:57:02',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:73904,num:6,uid:63,content:'你这个需求掉在夹缝里了\u003Cbr\u003E想让它失败,那应该是一个 restart 操作。但是这个操作是有损的\u003Cbr\u003E\u003Cbr\u003E建议还是先管理好服务器上的程序吧。',ipRegion:'',updatedByUid:0,createdAt:'2025-03-21 17:40:21',updatedAt:'2025-03-24 23:57:02',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:73905,num:7,uid:13654,content:'完整配置贴出来 把敏感信息打码',ipRegion:'',updatedByUid:0,createdAt:'2025-03-21 17:49:14',updatedAt:'2025-03-24 23:57:02',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:73906,num:8,uid:906,content:'nginx -t 可以检测 nginx 下所有配置文件 listen 端口冲突,因为这是基于当前 nginx 服务而言的,反向代理端口,是远程服务器端口,这是检测不到远程端口冲突的。',ipRegion:'',updatedByUid:0,createdAt:'2025-03-21 19:31:55',updatedAt:'2025-03-24 23:57:02',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:73907,num:9,uid:3681,content:'只能说你无法阻止有人比你还业余',ipRegion:'',updatedByUid:0,createdAt:'2025-03-21 22:25:28',updatedAt:'2025-03-24 23:57:02',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:73908,num:10,uid:849,content:'7503 那一行谁加的,谁的锅。如果没有堡垒机日志那就只能和稀泥',ipRegion:'',updatedByUid:0,createdAt:'2025-03-21 23:05:59',updatedAt:'2025-03-24 23:57:02',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:73909,num:11,uid:1100,content:'nginx -s reload 配置有问题会报出错误信息的。改配置后必须先 nginx -s reload 不出错才敢 service nginx restart ,否则就凉凉了。\u003Cbr\u003E\u003Cbr\u003EOP 用 nginx -s reload 看不到报错信息吗?',ipRegion:'',updatedByUid:0,createdAt:'2025-03-21 23:10:25',updatedAt:'2025-03-24 23:57:02',mentionNum:0,mentionedBy:[12,],mentionUsers:[],likeUsers:[],},{id:73910,num:12,uid:465,content:'#11 \u003Cbr\u003E#8 \u003Cbr\u003E\u003Cbr\u003E你俩到现在都没看明白 OP 这个环境是发生了什么问题\u003Cbr\u003E\u003Cbr\u003Enginx 的配置没有问题\u003Cbr\u003E\u003Cbr\u003E是 nginx 新监听的端口在外部被别人占用了\u003Cbr\u003E\u003Cbr\u003E因为占用 所以 nginx -s reload 是不生效的 \u003Cbr\u003E\u003Cbr\u003E\u003Cbr\u003E其实 OP 的吐槽是对的,这是 nginx reload 的一个问题 只是不太业余的运维大概率不会把自己弄到这个场景, 然后就没踩过这个坑\u003Cbr\u003E\u003Cbr\u003Enginx reload 确实应该在这里给一个 warning 或者 error 出来',ipRegion:'',updatedByUid:0,createdAt:'2025-03-22 00:33:09',updatedAt:'2025-03-24 23:57:02',mentionNum:11,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:73911,num:13,uid:906,content:'业余人员,多谢指点',ipRegion:'',updatedByUid:0,createdAt:'2025-03-22 09:27:25',updatedAt:'2025-03-24 23:57:02',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:73912,num:14,uid:2666,content:'不同的 app 绑定同一个地址,同一个端口,同一种协议只会有一个 accept ,其他情况内核都能自动区分处理。',ipRegion:'',updatedByUid:0,createdAt:'2025-03-22 09:52:10',updatedAt:'2025-03-24 23:57:02',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:73913,num:15,uid:63,content:'其实 看出来问题了啊。',ipRegion:'',updatedByUid:0,createdAt:'2025-03-22 12:25:55',updatedAt:'2025-03-24 23:57:02',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:73914,num:16,uid:1226,content:'你说你是业务运维,那估计就是有另外一个业余运维自己部署了反代 7503 ,没有和你说而已。',ipRegion:'',updatedByUid:0,createdAt:'2025-03-22 12:54:02',updatedAt:'2025-03-24 23:57:02',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},],usersMap:new Map([[1226,{uid:1226,url:'/u/3e1a712e6a045c766268506f1d51633e',avatar:'/a/3e1a712e6a045c766268506f1d51633e',username:'SenLief🤖',}],[849,{uid:849,url:'/u/1f187e076a045c77686e5f6f141b172d',avatar:'/a/1f187e076a045c77686e5f6f141b172d',username:'strobber16🤖',}],[465,{uid:465,url:'/u/172f00356a045c77646c536f4f081e7e',avatar:'/a/172f00356a045c77646c536f4f081e7e',username:'realpg🤖',}],[13654,{uid:13654,url:'/u/311c7b0f6a045d74666f526f1f5a150b',avatar:'/a/311c7b0f6a045d74666f526f1f5a150b',username:'BreadKiller🤖',}],[906,{uid:906,url:'/u/1402765a6a045c77696a506f0d2a3272',avatar:'/a/1402765a6a045c77696a506f0d2a3272',username:'coderzhangsan🤖',}],[63,{uid:63,url:'/u/1c187b5d6a045c77606c556f2d206420',avatar:'/a/1c187b5d6a045c77606c556f2d206420',username:'julyclyde🤖',}],[3681,{uid:3681,url:'/u/1d2647376a045c746662576f03051e7f',avatar:'/a/1d2647376a045c746662576f03051e7f',username:'duzhuo🤖',}],[13653,{uid:13653,url:'/u/693150256a045d74666f556f25500432',avatar:'/a/693150256a045d74666f556f25500432',username:'vincentWdp🤖',}],[2666,{uid:2666,url:'/u/2e7b5d156a045c75666c506f1b1e1b23',avatar:'/a/2e7b5d156a045c75666c506f1b1e1b23',username:'leconio🤖',}],[38,{uid:38,url:'/u/1d395e546a045c7760695e6f1d233e77',avatar:'/a/1d395e546a045c7760695e6f1d233e77',username:'busier🤖',}],[1100,{uid:1100,url:'/u/0b2d76226a045c76616a566f153e173e',avatar:'/a/0b2d76226a045c76616a566f153e173e',username:'yinmin🤖',}],[1008,{uid:1008,url:'/u/2c7b450c6a045c76606a5e6f0d183435',avatar:'/a/2c7b450c6a045c76606a5e6f0d183435',username:'seansong🤖',}],]),related:[{title:'请问 Nginx 怎么添加 CORS 白名单?',url:'/d/093d6b5b6a045c77606a5675445c606a3a0f0767',},{title:'Caddy \u0026amp;nginx 一键部署反代脚本 支持Debian/Ubuntu系统',url:'/d/3d08420f6a045c77606a5675465a636a1e392033',},{title:'分享一下用AdguardHome和Nginx的配置,让你可以自由DIY路径',url:'/d/6d10533f6a045c77606a5676415a626a0f273467',},{title:'adguard home的doh服务终于搭建成功了',url:'/d/69707b0c6a045c77606a567641586b6a5d361b64',},{title:'Nginx 四层反代 QUIC 如何传递客户端 IP',url:'/d/23317e046a045c77606a5671435a626a0a1a0562',},{title:'一个宝塔装两个网站怎么操作?在哪选占用端口,总不能都是80吧',url:'/d/6d0874286a045c77606a5670405c676a02273d03',},{title:'有闲置的服务器,只能用nginx,没办法开其他端口',url:'/d/177045276a045c77606a5672425d606a2f70251e',},],} const App={setup(){const goTo=useGoTo() const{mdAndUp}=useDisplay() return{goTo,mdAndUp}},data(){return data;},mounted(){const themeDark=localStorage.getItem("themeDark") if(themeDark!==null){this.theme.dark=JSON.parse(themeDark)} if(this.nav.post.total>(this.nav.post.currentPage-1)*100+20){let moreLen=100 if(this.nav.post.total({id:null,num:(this.nav.post.currentPage-1)*100+v,uid:null,content:null,ipRegion:null,updatedByUid:null,createdAt:null,updatedAt:null,mentionNum:null,mentionedBy:null,mentionUsers:null,likeUsers:null,})) this.posts.push(...morePosts.slice(20))} this.workerStart() const hash=window.location.hash const match=hash.match(/#(\d+)/) if(match){const n=parseInt(match[1],10) if(n>=(this.nav.post.currentPage-1)*100&&n{this.jumpTo(n)})}} this.$nextTick(()=>{this.addHeadingIds() tocbot.init({tocSelector:'.toc',contentSelector:'#post-content-0',headingSelector:'h2, h3, h4',headingsOffset:100,scrollSmoothOffset:-100,scrollSmooth:true,collapseDepth:6,onClick:function(e){setTimeout(()=>{history.replaceState(null,'',window.location.pathname+window.location.search)},0)},}) tocbot.refresh()});},beforeUnmount(){this.workerStop() if(this.quill){this.quill.destroy() this.quill=null}},computed:{dposts(){return this.posts.slice(20);},},created(){},methods:{successAlert(msg){this.alert={show:true,color:'success',text:msg,timeout:1500,}},failureAlert(msg){this.alert={show:true,color:'error',text:msg,timeout:5000,}},flipThemeDark(){this.theme.dark=!this.theme.dark localStorage.setItem("themeDark",JSON.stringify(this.theme.dark))},toSearch(){if(!this.search.text){this.failureAlert('搜索词不能为空') return} let keywords=this.search.text.trim() if(keywords.length<1){this.failureAlert('搜索词不能为空') return} if(keywords.length>100){this.failureAlert('搜索词过长') return} this.doSearch(keywords)},toReg(){window.location.href="/reg"},toLogin(){window.location.href="/login"},toPage(){let url=window.location.href url=url.replace(/(\/\d+)?(#[0-9]+)?$/,this.nav.post.targetPage>1?`/${this.nav.post.targetPage}`:'') window.location.href=url},toLoadRelated({done}){if(this.my&&this.my.uid){this.apiLoadRelated({done})}else{done('ok')}},workerStart(){this.nav.post.worker=setInterval(()=>{this.workerLoad()},500);},workerStop(){if(this.nav.post.worker){clearInterval(this.nav.post.worker);this.nav.post.worker=null;}},async jumpTo(num){const page=Math.floor(num/100)+1 const i=num-(page-1)*100 if(page===this.nav.post.currentPage){this.goTo("#post-"+num,this.nav.post.goToOptions) if(!this.posts[i].id){const block=Math.floor(num/20)+1 this.nav.post.apiLock[block]=true await this.apiLoadPosts(block) this.$nextTick(()=>{this.goTo("#post-"+num,this.nav.post.goToOptions)})}}else{let url=window.location.href url=url.replace(/(\/\d+)?(#[0-9]+)?$/,page>1?`/${page}`:'') url=url+"#"+num window.location.href=url}},postIntersect(num){return(isIntersecting,entries,observer)=>{if(isIntersecting){this.nav.post.task.push(num) this.nav.post.active.push(num) this.nav.post.active=this.nav.post.active.filter(item=>Math.abs(item-num)<=5) this.nav.post.active.sort((a,b)=>a-b)}else{this.nav.post.active=this.nav.post.active.filter(item=>item!==num)} if(this.nav.post.active[0]){this.nav.post.anchor=this.nav.post.active[0]}else{this.nav.post.anchor=0}}},async apiLoadPosts(block){try{const response=await axios.post('/fapi/v1/post/block/'+block,{discussionId:this.nav.post.discussionId,}) if(response.data.code===0){response.data.data.posts.forEach(post=>{const i=post.num%100 Object.assign(this.posts[i],post)}) response.data.data.users.forEach(user=>{this.usersMap.set(user.uid,user)})}else{this.failureAlert('回帖数据加载失败: '+response.data.msg)}}catch(error){this.failureAlert('回帖数据加载失败: '+error)} this.nav.post.apiLock[block]=false},workerLoad(){while(this.nav.post.task.length){const num=this.nav.post.task.pop() const i=num-(this.nav.post.currentPage-1)*100 if(!this.posts[i].id){const block=Math.floor(num/20)+1 if(!this.nav.post.apiLock[block]){this.nav.post.apiLock[block]=true this.apiLoadPosts(block)}}}},getTimeInfo(t){if(!t){return ""} const now=new Date();const then=new Date(t);const diff=now-then;const minute=60*1000;const hour=minute*60;const day=hour*24;const month=day*30;const year=month*12;if(diffpost.num===num) if(!post){return "#"+num} const uid=post.uid const username=this.usersMap.get(uid)?.username if(!username){return "#"+num} return username},getUsernameByPostId(id){const post=this.posts.find(post=>post.id===id) if(!post){return "#"+this.getPostNumByPostId(id)} const uid=post.uid const username=this.usersMap.get(uid).username if(!username){return "#"+this.getPostNumByPostId(id)} return username},getPostNumByPostId(id){const post=this.posts.find(post=>post.id===id) return post.num},getPostById(id){const post=this.posts.find(post=>post.id===id) return post},getPostByNum(num){const post=this.posts.find(post=>post.num===num) return post},getAvatarByUid(uid){const avatar=this.usersMap.get(uid)?.avatar if(!avatar){return this.getRandomAvatar()} return avatar},getAvatarByPostNum(num){const post=this.posts.find(post=>post.num===num) if(!post){return this.getRandomAvatar()} const uid=post.uid return this.getAvatarByUid(uid)},getRandomAvatar(){const num=Math.floor(Math.random()*100) return "https://randomuser.me/api/portraits/men/"+num+".jpg"},getUrlByUid(uid){const url=this.usersMap.get(uid)?.url if(!url){return ""} return url},getTextByPostNum(num){const post=this.posts.find(post=>post.num===num) if(!post||!post.content){return '点击跳转到#'+num+'查看'} const parser=new DOMParser() const doc=parser.parseFromString(post.content,'text/html') const text=doc.body.textContent||'' return text.slice(0,100)},addHeadingIds(){const content=document.getElementById('post-content-0') if(!content){this.nav.showTOC=false return} const headings=content.querySelectorAll('h2, h3, h4') headings.forEach((heading,index)=>{if(!heading.id){heading.id=`toc-nav-${index}`}}) if(headings.length==0){this.nav.showTOC=false}},async doSearch(keywords){this.search.loading=true try{const response=await axios.post('/fapi/v1/search',{keywords:keywords,}) if(response.data.code===0){if(response.data.data.hash&&response.data.data.hash.length===32){window.location.href="/s/"+response.data.data.hash}else{this.failureAlert('搜索失败: 搜索服务异常')}}else{this.failureAlert('搜索失败: '+response.data.msg)}}catch(error){this.failureAlert('搜索失败: '+error)} this.search.loading=false},debounce(fn,delay){let timer=null return function(...args){if(timer)clearTimeout(timer) timer=setTimeout(()=>{fn.apply(this,args)},delay);};},},watch:{'nav.post.targetPage':{handler:async function(newV,oldV){this.toPage()},immediate:false},},} const vuetify=createVuetify({defaults:{global:{ripple:true,},},}) const app=createApp(App) app.use(vuetify).mount("#app")