linux中apache、nginx的proxy反向代理配置

互联网 2022/1/14 7:08:29

apache-proxy-配置反向代理.conf<VirtualHost *:80>DocumentRoot "/www/admin/www.ikugui.cc_9527/wwwroot/public/"ServerName "1636965547"ServerAlias zb.ikugui.cc#代理设置SSLProxyEngine OnProxyRequests OffProxyPreserveHost OnRequest…

apache-proxy-配置反向代理.conf

 

<VirtualHost *:80>
    DocumentRoot "/www/admin/www.ikugui.cc_9527/wwwroot/public/"
    ServerName "1636965547"
    ServerAlias zb.ikugui.cc

    #代理设置
    SSLProxyEngine On
    ProxyRequests Off
    ProxyPreserveHost On
    RequestHeader set Host zb.ikugui.cc
    ProxyPass / http://111.229.53.23:8099//
    ProxyPassReverse / http://111.229.53.23:8099//
    CustomLog "|/usr/local/phpstudy/system/module/rotatelogs /www/admin/www.ikugui.cc_9527/log/apache_access_%Y-%m-%d.log 86400 480" combined_with_cookie
RewriteEngine on
    RewriteCond %{HTTPS} !=on
    RewriteRule ^(.*) https://%{SERVER_NAME}$1 [L,R]
</VirtualHost>

<VirtualHost *:443>
    DocumentRoot "/www/admin/www.ikugui.cc_9527/wwwroot/public/"
    ServerName "1636965547"
    ServerAlias "zb.ikugui.cc"

    #开启SSL
    SSLEngine on
    SSLCertificateFile "/usr/local/phpstudy/certs/zb.ikugui.cc/zb.ikugui.cc_apache_public.crt"
    SSLCertificateKeyFile "/usr/local/phpstudy/certs/zb.ikugui.cc/zb.ikugui.cc_apache.key"
    SSLCertificateChainFile "/usr/local/phpstudy/certs/zb.ikugui.cc/zb.ikugui.cc_apache_chain.crt"
    SSLProtocol all -SSLv3

    #代理设置
    SSLProxyEngine On
    ProxyRequests Off
    ProxyPreserveHost On
    RequestHeader set Host zb.ikugui.cc
    ProxyPass / http://111.229.53.23:8099//
    ProxyPassReverse / http://111.229.53.23:8099//


        CustomLog "|/usr/local/phpstudy/system/module/rotatelogs /www/admin/www.ikugui.cc_9527/log/apache_access_%Y-%m-%d.log 86400 480" combined_with_cookie
</VirtualHost>

 

 

nginx-proxy-配置反向代理.conf

 

server{
    listen 80 ;
    server_name zb.ikugui.cc ;

    #代理配置
    location /{
        proxy_set_header X-Original-Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Host zb.ikugui.cc:$server_port;
        proxy_pass http://111.229.53.23:8099//;
    }
    access_log /www/admin/www.ikugui.cc_9527/log/nginx_access_$logdate.log main;

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

server{
    listen 443 ssl;
    server_name zb.ikugui.cc;

    #开启SSL
    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;

    #证书文件
    ssl_certificate /usr/local/phpstudy/certs/zb.ikugui.cc/zb.ikugui.cc_nginx_public.crt;
    ssl_certificate_key /usr/local/phpstudy/certs/zb.ikugui.cc/zb.ikugui.cc_nginx.key;

    #代理配置
    location /{
        proxy_set_header X-Original-Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Host zb.ikugui.cc:$server_port;
        proxy_pass http://111.229.53.23:8099//;
    }
    access_log /www/admin/www.ikugui.cc_9527/log/nginx_access_$logdate.log main;

}

 nginx容器的配置demo

server {
    listen       80;
    server_name  localhost;

    location / {
        root   /usr/share/nginx/html/public;
        index  index.html index.htm index.php;
    }

    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   /usr/share/nginx/html/public;
    }

    location ~ \.php$ {
        fastcgi_pass   php:9000;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  /www/public/$fastcgi_script_name;
        include        fastcgi_params;
    }
}

 

随时随地学软件编程-关注百度小程序和微信小程序
关于找一找教程网

本站文章仅代表作者观点,不代表本站立场,所有文章非营利性免费分享。
本站提供了软件编程、网站开发技术、服务器运维、人工智能等等IT技术文章,希望广大程序员努力学习,让我们用科技改变世界。
[linux中apache、nginx的proxy反向代理配置]http://www.zyiz.net/tech/detail-284954.html

赞(0)
关注微信小程序
程序员编程王-随时随地学编程

扫描二维码或查找【程序员编程王】

可以随时随地学编程啦!

技术文章导航 更多>
扫一扫关注最新编程教程