使用frp進(jìn)行內(nèi)網(wǎng)http/https代理

獲取

官方項(xiàng)目地址:https://github.com/fatedier/frp

www.hewei.work A 記錄配置公網(wǎng)ip x.x.x.x

服務(wù)端安全組放開80 443 7000端口

服務(wù)端配置(x.x.x.x)

[common]

bind_port = 7000

vhost_http_port = 80

vhost_https_port = 443

token = hyc

[http_web]

type = http

custom_domains = www.hewei.work

[https_web]

type = https

custom_domains = www.hewei.work

開機(jī)啟動(dòng)

配置systemctl來控制,服務(wù)端運(yùn)行

vim新建文件并寫入配置內(nèi)容

vim /usr/lib/systemd/system/frp.service

寫入以下內(nèi)容,注意上文移動(dòng)放置的路徑和此處有關(guān)。這里是啟動(dòng)的服務(wù)端。

[Unit]

Description=The nginx HTTP and reverse proxy server

After=network.target remote-fs.target nss-lookup.target

[Service]

Type=simple

ExecStart=/usr/local/frp/frps -c /usr/local/frp/frps.ini

KillSignal=SIGQUIT

TimeoutStopSec=5

KillMode=process

PrivateTmp=true

StandardOutput=syslog

StandardError=inherit

[Install]

WantedBy=multi-user.target

重新加載服務(wù)的配置文件

systemctl daemon-reload

啟動(dòng)/停止/重啟,查看狀態(tài),設(shè)置開機(jī)自啟/關(guān)閉開機(jī)自啟

systemctl start frp

systemctl status frp

systemctl enable frp

systemctl disable frp

客戶端配置(172.118.59.84)

[common]

server_addr = x.x.x.x

server_port = 7000

token= hyc

[http_web]

type = http

local_ip = 172.118.59.84

local_port = 8000

custom_domains = www.hewei.work

[https_web]

type = https

local_ip = 172.118.59.84

local_port = 4433

custom_domains = www.hewei.work

后臺(tái)啟動(dòng)客戶端

nohup ./frpc -c ./frpc.ini &

訪問

http://www.hewei.work/

https://www.hewei.work/

配置nginx

server {

? ? ? ? listen? ? ? 80;

? ? ? ? #listen? ? ? [::]:80;

? ? ? ? listen? ? ? 443 ssl http2;

? ? ? ? #listen? ? ? [::]:443 ssl http2;

? ? ? ? server_name? www.hewei.work,www.kivvipos.com;

? ? ? ? root? ? ? ? /usr/share/nginx/html;

? ? ? ? # Settings for a TLS enabled server.

? ? ? ? if ($server_port !~ 443){

? ? ? ? ? ? rewrite ^(/.*)$ https://$host$1 permanent;

? ? ? ? }

? ? ? ? proxy_connect_timeout 180;

? ? ? ? proxy_send_timeout 180;

? ? ? ? proxy_read_timeout 180;

? ? ? ? proxy_set_header Host $host;

? ? ? ? proxy_set_header X-Forwarder-For $remote_addr;

? ? ? ? proxy_set_header Upgrade $http_upgrade;

? ? ? ? proxy_set_header Connection "Upgrade";

? ? ? ? ssl_certificate "/etc/nginx/hewei.work_nginx/hewei.work_bundle.crt";

? ? ? ? ssl_certificate_key "/etc/nginx/hewei.work_nginx/hewei.work.key";

? ? ? ? ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3;

? ? ? ? ssl_session_cache shared:SSL:1m;

? ? ? ? ssl_session_timeout? 10m;

? ? ? ? ssl_ciphers HIGH:!aNULL:!MD5;

? ? ? ? ssl_prefer_server_ciphers on;

? ? ? ? # Load configuration files for the default server block.

? ? ? ? include /etc/nginx/default.d/*.conf;

? ? ? ? location / {

? ? ? ? ? ? #proxy_pass http://www.hewei.work;

? ? ? ? ? ? proxy_pass http://127.0.0.1:8080/;

? ? ? ? }

? ? ? ? error_page 404 /404.html;

? ? ? ? location = /404.html {

? ? ? ? }

? ? ? ? error_page 500 502 503 504 /50x.html;

? ? ? ? location = /50x.html {

? ? ? ? }

? ? }

注意項(xiàng):

參考:

https://developer.aliyun.com/article/853534?spm=ding_open_doc.document.0.0.14bc722fV6pBDC

https://zhuanlan.zhihu.com/p/371234742

http://blog.zhaojishun.cn/articles/2021/03/26/1616753494067.html

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容