1.服务器背景
这台机子已经运行了很久的wordpress,https是最近才加上的。等于有一台服务器预装了BT+wordpress,,所以只需要再安装xray即可。这篇文章的起因是以前搭建博客时没有想怎么和其他服务共用443端口,在使用一键脚本搭建xray时,发现二者直接搭建是不能实现共存的。
2.开始搭建
首先介绍一下完整过程、出现的问题和解决方法。
这里参考了波仔的做法:https://www.v2rayssr.com/xraybt.html
2.1 安装宝塔和相关环境
搭建宝塔的步骤这里就不展开了,具体看波仔的帖子,值得注意的有几点:
- 不一定需要安装aapanel(宝塔国际版),普通版的宝塔也是可以做到的
- 在cloudflare解析时不要开启小云朵,亲测搭建完开启cf加速是没有办法连接的,申请证书的时候也有影响
- 也不一定需要1G的内存,512M内存加swap也是可以做到的
- BBR不一定要开,自己选择(链接:https://www.v2rayssr.com/bbr.html)
- 在安装完宝塔安装LNMP时建议五个组件全装而不是像视频中波仔一样安装部分组件,建议安装插件上的系统防火墙,管理防火墙很方便
2.2 安装Xray并调试
首先我们安装Xray的官方版本
bash -c "$(curl -L https://github.com/XTLS/Xray-install/raw/main/install-release.sh)" @ install -u root
然后生成一个随机编码备用
cat /proc/sys/kernel/random/uuid # 粘贴到VPS运行即可生成 UUID
安装完成后,在VPS目录 /usr/local/etc/xray 找到 config,json 文件,粘贴下面的配置文件
(下面的三处域名是必须修改的)
首先这里是xray的vless+xtls模式:
{
"log": {
"loglevel": "warning"
},
"inbounds": [
{
"listen": "0.0.0.0",
"port": 443,
"protocol": "vless",
"settings": {
"clients": [
{
"id": "5272bc0d-9852-4af7-b2f0-979b1faf2973",
//此处改为你的UUID
"level": 0,
"email": "[email protected]",
//此处为邮箱地址,随便填
"flow":"xtls-rprx-direct"
}
],
"decryption": "none",
"fallbacks": [
{
"alpn": "h2",
"dest": 8002 //此处为回落端口,若更改,请更改后面Nginx的相应配置
}
]
},
"streamSettings": {
"network": "tcp",
"security": "xtls",
"xtlsSettings": {
"serverName": "qq.bozai.us", //修改为你的域名
"alpn": [
"h2",
"http/1.1"
],
"certificates": [
{
"certificateFile": "/www/server/panel/vhost/cert/qq.bozai.us/fullchain.pem", //修改为你的域名
"keyFile": "/www/server/panel/vhost/cert/qq.bozai.us/privkey.pem" //修改为你的域名
}
]
}
}
}
],
"outbounds": [
{
"protocol": "freedom",
"settings": { }
}
]
}
下面是trojan的修改方法:
{
"log": {
"loglevel": "warning"
},
"inbounds": [
{
"listen": "0.0.0.0",
"port": 443,
"protocol": "trojan",
"settings": {
"clients": [
{
"password":"440221",
"email": "[email protected]", //此处为邮箱地址,随便修改
"level": 0,
"flow": "xtls-rprx-direct"
}
],
"decryption": "none",
"fallbacks": [
{
"dest": 2222 //此处为回落端口,若更改,请更改后面Nginx的相应配置
}
]
},
"streamSettings": {
"network": "tcp",
"security": "tls",
"tlsSettings": {
"serverName": "oliverhou.com", //修改为你的域名
"alpn": [
"h2",
"http/1.1"
],
"certificates": [
{
"certificateFile": "/www/server/panel/vhost/cert/oliverhou.com/fullchain.pem", //修改为你的域名 注意证书的位置 破解版宝塔把cert改成ssl
"keyFile": "/www/server/panel/vhost/cert/oliverhou.com/privkey.pem" //修改为你的域名 注意证书的位置 破解版宝塔把cert改成ssl
}
]
}
}
}
],
"outbounds": [
{
"protocol": "freedom",
"settings": { }
}
]
}
最后补充一下多协议同端口回落
{
"log": {
"loglevel": "warning"
},
"inbounds": [
{
"listen": "0.0.0.0",
"port": 443,
"protocol": "trojan",
"settings": {
"clients": [
{
"password":"440221",
"email": "[email protected]", //此处为邮箱地址,随便修改
"level": 0,
"flow": "xtls-rprx-direct"
}
],
"decryption": "none",
"fallbacks": [
{
"dest": 2222 //此处为回落端口,若更改,请更改后面Nginx的相应配置
}
]
},
"streamSettings": {
"network": "tcp",
"security": "tls",
"tlsSettings": {
"serverName": "oliverhou.com", //修改为你的域名
"alpn": [
"h2",
"http/1.1"
],
"certificates": [
{
"certificateFile": "/www/server/panel/vhost/cert/oliverhou.com/fullchain.pem", //修改为你的域名 注意证书的位置 破解版宝塔把cert改成ssl
"keyFile": "/www/server/panel/vhost/cert/oliverhou.com/privkey.pem" //修改为你的域名 注意证书的位置 破解版宝塔把cert改成ssl
}
]
}
}
}
,//每个协议块用,号隔开
{
"listen": "0.0.0.0",
"port": 443,
"protocol": "vless",
"settings": {
"clients": [
{
"id": "3e708264-834f-4c23-a40c-cfe9ae958f11", //此处改为你的UUID
"level": 0,
"email": "[email protected]", //此处为邮箱地址,随便修改
"flow":"xtls-rprx-direct"
}
],
"decryption": "none",
"fallbacks": [
{
"alpn": "h2",
"dest": 2222 //此处为回落端口,若更改,请更改后面Nginx的相应配置
}
]
},
"streamSettings": {
"network": "tcp",
"security": "xtls",
"xtlsSettings": {
"serverName": "oliverhou.com", //修改为你的域名
"alpn": [
"h2",
"http/1.1"
],
"certificates": [
{
"certificateFile": "/www/server/panel/vhost/cert/oliverhou.com/fullchain.pem", //修改为你的域名 注意证书的位置 破解版宝塔把cert改成ssl
"keyFile": "/www/server/panel/vhost/cert/oliverhou.com/privkey.pem" //修改为你的域名 注意证书的位置 破解版宝塔把cert改成ssl
}
]
}
}
}
],
"outbounds": [
{
"protocol": "freedom",
"settings": { }
}
]
}
其实还可以添加更多的协议,或者每个协议都可以用不同的端口,然后在网站配置中添加相应修改,这里就不再赘述
这里如果不熟悉的朋友可以直接输入指令vi /usr/local/etc/xray/config,json 使用vim修改(或者用宝塔的文件管理更方便)
完成上述步骤后,需要为我们的网站申请证书(我的已经有了就不演示了,波仔帖子这里没问题,注意,不要开启强制https,因为后面我们修改nginx会把80重定向至443就已经相当于强制https了,开启会导致重定向过多)
搞定这一步就来到了网站设置界面(这里注意,波仔的帖子并不适用于所有情况,具体看下面)
在宝塔里打开网站设置界面,找到配置文件这一选项
首先在代码第一行插入如下代码(记得修改两处域名为你自己的域名)
server {
listen 0.0.0.0:80;
server_name qq.bozai.us;#这里要改为自己的域名
return 301 https://qq.bozai.us$request_uri;
}
然后修改下一个server块内的代码
注释443那一行,然后修改listen 80的那一行为listen 回落端口 http2
注意:这里的回落端口就是上面xray配置文件中对应的Dest端口
然后把原有的443那一行注释掉(搭建wordpress时没有开启https的可能没有这一行,可忽略这个提示)
最后加入一行代码,保持我们的博客访问时的格式
add_header Content-Security-Policy "upgrade-insecure-requests";
到这里就修改完了,具体参考如下图
最后我们测试一下xray
分别输入下面命令,查看 Xray 是否正常运行,若是有问题,就是配置文件出错
systemctl restart nginx
systemctl status nginx
systemctl restart xray
systemctl status xray
如图,就是ok了
接下来就是在v2rayN里配置相关的信息并导出节点连接,具体配置如图(trojan的也是类似)
(注意:clash并不支持vless,所以更推荐大家使用trojan的fallback)
最后这里说几个问题
1.首先是上面提到的,开启CDN无法连接,貌似在vless+xtls或者trojan下cdn加速(点亮小云朵)xray是没有办法工作的(具体情况不详,也可能是我记错了),所以在解析域名时要么直接不用cloudflare用自家的域名解析最好,或者不开启小云朵即可
2.第二,在开启https后访问网页可能会提示重定向过多,或者使用了ssl插件也可能会出现这种情况,这时候就需要修改配置文件了,具体操作看这个帖子
https://www.wppop.com/wordpress-https-you-cannot-visit-this-page.html
3.第二点不生效可能是证书问题,或者是特殊情况,必要时还需要使用phpadmin进数据库修改wp-option表中的字段,这也是我前面说的建议最好五个插件全都装,不是所有人都会mysql -u -p进数据库的
4.还有不明白直接看project X的文档最直截了当
https://xtls.github.io/Xray-docs-next/
5.上面的xray配置文件如果报错,尝试删除所有//后面的中文备注
6.该教学仅供参考,读者需遵守法律,热爱国家,不应将其用于非法活动
有问题可以在下面留言
Thanks for your blog, nice to read. Do not stop.
In all your gettings, get wisdom.
mesleki faaliyetlerinin tamamını veya önemli bir bölümünü ceza hukuku alanında yoğunlaştırmış
I抦 impressed, I must say. Really rarely do I encounter a weblog that抯 each educative and entertaining, and let me tell you, you’ve gotten hit the nail on the head. Your concept is outstanding; the difficulty is something that not enough people are speaking intelligently about. I am very completely happy that I stumbled across this in my search for one thing relating to this.
There are some attention-grabbing cut-off dates on this article however I don抰 know if I see all of them heart to heart. There’s some validity however I will take maintain opinion till I look into it further. Good article , thanks and we want extra! Added to FeedBurner as properly
Once I initially commented I clicked the -Notify me when new comments are added- checkbox and now each time a remark is added I get four emails with the identical comment. Is there any approach you may remove me from that service? Thanks!
The following time I read a weblog, I hope that it doesnt disappoint me as much as this one. I imply, I do know it was my choice to read, however I actually thought youd have something attention-grabbing to say. All I hear is a bunch of whining about one thing that you might repair in the event you werent too busy searching for attention.
Can I just say what a aid to seek out somebody who really knows what theyre speaking about on the internet. You undoubtedly know find out how to carry a difficulty to mild and make it important. More people need to learn this and perceive this aspect of the story. I cant imagine youre not more in style because you positively have the gift.
Thank you a lot for providing individuals with a very breathtaking possiblity to read in detail from this site. It can be so terrific and packed with a lot of fun for me and my office co-workers to search your site no less than 3 times a week to see the fresh items you have got. And lastly, I am just certainly happy concerning the fabulous techniques you give. Selected 4 tips in this posting are completely the best we’ve ever had.
I would like to convey my passion for your generosity for folks who actually need help with your concern. Your real commitment to getting the solution all-around had become particularly effective and have in every case allowed people just like me to reach their endeavors. Your insightful suggestions means much to me and a whole lot more to my peers. Regards; from everyone of us.
I really wanted to type a message to be able to say thanks to you for those amazing information you are giving here. My time-consuming internet look up has finally been honored with excellent facts to talk about with my great friends. I ‘d say that many of us site visitors actually are definitely lucky to live in a wonderful community with so many marvellous professionals with insightful suggestions. I feel very much grateful to have discovered the webpage and look forward to really more enjoyable minutes reading here. Thank you again for everything.
I truly wanted to compose a small note to be able to say thanks to you for all of the splendid ideas you are placing on this website. My rather long internet search has at the end of the day been honored with incredibly good ideas to talk about with my best friends. I would express that many of us readers actually are very much lucky to exist in a fabulous site with many brilliant professionals with very helpful basics. I feel very privileged to have seen your entire web site and look forward to many more fun moments reading here. Thanks once more for everything.
I and my buddies were examining the best helpful hints from your web site and all of the sudden I had an awful feeling I had not expressed respect to the site owner for those tips. All of the ladies became excited to read all of them and have in effect honestly been enjoying these things. Many thanks for truly being considerably helpful as well as for picking out varieties of helpful guides most people are really desperate to understand about. My personal honest apologies for not expressing appreciation to you sooner.
I intended to draft you this tiny remark to thank you so much again about the exceptional techniques you’ve provided in this case. It has been certainly shockingly generous of people like you to grant publicly what exactly a number of people could possibly have marketed as an ebook to get some profit on their own, most notably now that you could have done it if you ever wanted. The creative ideas likewise worked like the good way to comprehend the rest have a similar fervor the same as my personal own to figure out way more with regards to this issue. Certainly there are many more enjoyable situations up front for individuals that examine your website.
I precisely had to thank you so much again. I’m not certain the things that I could possibly have taken care of without the actual ideas shown by you concerning my problem. It actually was a very depressing situation for me, however , being able to view your skilled form you treated it forced me to cry for gladness. I am grateful for the help and in addition pray you comprehend what a great job your are getting into teaching people today through the use of your webpage. Most probably you’ve never encountered any of us.
I together with my friends were found to be viewing the great items on your web page and so quickly I got an awful feeling I never thanked you for those secrets. All the young men happened to be consequently excited to study them and have seriously been having fun with these things. Appreciation for genuinely very accommodating and for picking out this kind of marvelous information most people are really needing to learn about. My personal sincere regret for not expressing appreciation to you sooner.
Thanks so much for giving everyone an extraordinarily nice possiblity to check tips from this site. It is often very terrific and full of a great time for me and my office acquaintances to visit your site the equivalent of thrice in one week to study the latest guidance you have. And lastly, we’re actually happy with all the extraordinary tips served by you. Selected 3 facts on this page are unquestionably the finest we have ever had.
I definitely wanted to send a brief message so as to express gratitude to you for the marvelous information you are writing on this website. My time intensive internet investigation has at the end been honored with sensible points to exchange with my contacts. I ‘d express that most of us readers are unequivocally endowed to exist in a magnificent community with so many perfect professionals with interesting opinions. I feel extremely grateful to have discovered your entire webpage and look forward to many more excellent moments reading here. Thank you once more for everything.
I actually wanted to send a message to be able to say thanks to you for these awesome strategies you are writing on this site. My long internet look up has now been paid with high-quality strategies to write about with my family and friends. I would tell you that many of us site visitors are definitely endowed to live in a notable community with many outstanding people with insightful strategies. I feel extremely fortunate to have come across your entire website and look forward to so many more fun minutes reading here. Thank you once more for all the details.
I together with my pals ended up viewing the good advice found on your website and then then came up with a horrible suspicion I never expressed respect to the website owner for those strategies. All of the ladies were definitely absolutely excited to study them and have now pretty much been loving those things. We appreciate you truly being really kind and then for figuring out varieties of excellent issues most people are really wanting to be informed on. Our honest apologies for not expressing gratitude to you sooner.
I and my buddies ended up viewing the good hints on your website then immediately I got an awful suspicion I never expressed respect to you for those strategies. All the young boys were definitely for that reason warmed to read through all of them and now have in truth been taking advantage of those things. Thank you for actually being well accommodating and for settling on these kinds of tremendous issues most people are really needing to know about. My honest apologies for not saying thanks to sooner.
Thank you a lot for giving everyone an extremely memorable opportunity to read articles and blog posts from this site. It is always so useful plus full of a good time for me and my office colleagues to search your web site really 3 times in a week to find out the fresh guidance you have got. And of course, I’m actually motivated with your awesome guidelines you give. Selected 1 areas in this article are in fact the most beneficial we’ve ever had.
Thank you for each of your efforts on this site. My daughter takes pleasure in carrying out internet research and it’s easy to understand why. Almost all know all relating to the dynamic way you deliver advantageous guides on your website and as well increase participation from some others on the issue while our girl has always been discovering a whole lot. Enjoy the remaining portion of the year. You’re carrying out a wonderful job.
I wish to express my appreciation to you for rescuing me from this type of circumstance. As a result of looking out through the world wide web and finding recommendations which are not productive, I assumed my life was done. Existing without the presence of approaches to the problems you have solved by way of the guideline is a crucial case, as well as ones that could have adversely damaged my entire career if I hadn’t encountered your web blog. Your actual skills and kindness in handling almost everything was very useful. I am not sure what I would’ve done if I had not come upon such a thing like this. I can at this moment look ahead to my future. Thank you so much for your expert and effective help. I won’t be reluctant to suggest your blog post to any individual who should have recommendations about this area.
I am commenting to let you know of the brilliant discovery my friend’s daughter obtained reading through the blog. She came to find a lot of details, which include what it’s like to have an amazing teaching spirit to get others easily fully grasp several complex things. You actually exceeded visitors’ desires. Many thanks for imparting the powerful, healthy, educational and even cool thoughts on your topic to Janet.
I needed to send you this bit of observation just to thank you as before about the remarkable principles you have contributed on this website. It is really shockingly open-handed of you giving without restraint all many individuals would have distributed for an ebook to end up making some bucks on their own, particularly seeing that you might have done it in the event you considered necessary. Those tricks additionally acted to be the fantastic way to fully grasp many people have similar passion much like my own to realize lots more with regard to this condition. Certainly there are numerous more enjoyable situations in the future for those who looked at your site.
Thanks for every one of your labor on this website. My niece enjoys getting into research and it’s really obvious why. Most of us hear all about the compelling way you make helpful tips by means of your web site and as well increase response from others about this concept so my princess is discovering so much. Take advantage of the remaining portion of the new year. You have been doing a powerful job.
I’m extremedly inspikred wirh yoour wriiting talents aas wwell
aas with the struture tto your weblog. Is thos a paid subject matter or did you
odify itt your self? Either wayy kewp up tthe nice quality
writing, it’s rzre to see a great log like this one nowadays..
I simply needed to say thanks once again. I am not sure the things I might have accomplished without these smart ideas shared by you over such subject. Previously it was an absolute challenging dilemma in my position, but looking at a new professional fashion you managed the issue took me to cry for gladness. I’m thankful for your assistance and in addition have high hopes you are aware of an amazing job that you are providing instructing some other people thru your websites. Probably you haven’t encountered all of us.
I as well as my pals came checking the good ideas from your web blog and then before long came up with a horrible feeling I never expressed respect to you for those secrets. Those men were totally joyful to read all of them and already have without a doubt been taking advantage of them. Thank you for being quite kind and for having these kinds of very good areas millions of individuals are really wanting to know about. My sincere apologies for not expressing gratitude to you sooner.
My wife and i felt really cheerful that Emmanuel managed to round up his research through the entire precious recommendations he acquired out of the web pages. It is now and again perplexing to just choose to be giving away facts which people may have been making money from. And we also take into account we need the writer to thank for that. The specific explanations you have made, the easy blog menu, the relationships your site help foster – it’s got many awesome, and it’s really helping our son and our family believe that that theme is amusing, and that’s very important. Many thanks for the whole thing!
Thanks a lot for giving everyone an exceptionally terrific opportunity to check tips from this site. It’s always very brilliant and full of fun for me personally and my office acquaintances to visit your site at a minimum three times in one week to read through the newest tips you will have. And definitely, I’m certainly happy concerning the mind-boggling things served by you. Some two tips in this article are unequivocally the most impressive we have all ever had.
I enjoy you because of all your valuable work on this website. Betty enjoys working on research and it is obvious why. A lot of people know all of the lively ways you convey very helpful tricks on your website and in addition encourage contribution from some others on this article plus our own girl is certainly understanding a great deal. Take pleasure in the remaining portion of the year. You are performing a great job.
Finee waay of explaining, and good artihle to take facs onn thee toipic of my presentation topic, which i amm goinbg to present
in university.
We’re a grooup off volunhteers andd starting a new scheme in our community.
Yourr websit offered us with valuable informtion to work on.
You’ve done a fotmidable joob and our whope community will bbe tnankful to you.
I’m retty pleased to discoveer this great site. I wanmt to to thank
yoou for your tkme for this fantastic read!! I definitely liked evey bit of it andd
I hae yyou saved to fav to loolk at neew information in your
webb site.
I’m gone to say tto mmy little brother, thjat he should alpso pay a visit
this weeb site on regukar bassis too obtain updated from latest gossip.
An intereating discussion iss worth comment. I do tjink that yoou ned tto write more
onn thos issue, it might not be a taboo matte but generally peoplle ddo not ttalk about thes issues.
To thee next! Kind regards!!
I’m impressed, I must say. Seeldom do I ecounter a blog
that’s both educative aand entertaining, andd
let mme tell you, you have hitt thee nail on thee head.
The prblem is something tthat not enough meen and womedn are speaking intelligbently about.
Noow i’m vdry hapoy that I came across this during my search foor skmething regarding this.
Wow, that’s what I was seeking for, what a material! present here at this blog, thanks admin of this web site.
When I originalpy comnmented I coicked tthe “Notify me when new comments are added” checkbox
and now eac timme a comment iss added I gett tthree e-mails with thee sme comment.
Is there any way you can remove people ftom thatt service?
Bleess you!
I wass suggested ths wweb site by my cousin. I’m noot ssure whether this post is wrritten by him aas noo oone ekse knoow uch detailed about mmy
difficulty. You are incredible! Thanks!
Appreciating thhe persistrence you puut into yiur ssite and
inn deptgh information youu provide. It’s good
tto come across a blog eveey oncfe iin a while that isn’t tthe same outt off date rehashed information.Wonderfuul read!
I’ve saved your sire and I’m adding yur RSS feeds to myy Googe
account.
Hello everyone, it’s my fiurst go tto ssee at
thus website, annd piecee oof wrfiting is truly fruitful in favor oof me, eep
up posting sujch articles orr reviews.
Good article with great ideas! Thank you for this important article. Thank you very much for this wonderful information.