1、配置nginx反向代理,實現(xiàn)api.x.com域名代理本地9001端口

1????使用腳本安裝nginx服務器:

圖1

#安裝相關編譯包

yum install -y vim lrzsz tree screen psmisc lsof tcpdump wget ntpdate gcc gcc-c++ glibc glibc-devel pcre pcre-devel openssl openssl-devel systemd-devel net-tools iotop bc zip unzip zlib-devel bash-completion nfs-utils automake libxml2 libxml2-devel libxslt libxslt-devel perl perl-ExtUtils-Embed

#創(chuàng)建用戶

useradd -r -s /sbin/nologin nginx

#給nginx權限

chown nginx.nginx -R /apps/nginx/

#解壓縮

tar xvf? nginx-1.14.2.tar.gz

cd nginx-1.14.2/

#源碼編譯

./configure --prefix=/apps/nginx \

--user=nginx \

--group=nginx \

--with-http_ssl_module \

--with-http_v2_module \

--with-http_realip_module \

--with-http_stub_status_module \

--with-http_gzip_static_module \

--with-pcre \

--with-stream \

--with-stream_ssl_module \

--with-stream_realip_module

make && make install

#配置變量環(huán)境

echo 'PATH=/apps/nginx/sbin/:$PATH' > /etc/profile.d/nginx.sh

. /etc/profile.d/nginx.sh

#此處由于nginx的二進制只有一個nginx,所以可以使用軟鏈接的方式來配置:

#ln -s /apps/nginx/sbin/nginx /usr/sbin/

2????先配置nginx服務器讓其監(jiān)聽在9001端口:

圖3

3????然后設置其代理:

圖4

4????設置默認的頁面為:

圖5

5????通過瀏覽器訪問,這樣就實現(xiàn)了本地的代理:

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

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