Nginx反向代理简单配置
2024-09-02 10:13:13
一、首先在IIS中部署两个站点,localhost:86 、localhost:5000
二、修改C:\windows\system32\drivers\etc\hosts文件,增加 127.0.0.1 test1.yubay.cn 、127.0.0.1 test2.yubay.cn 两个Ip 域名映射
三、修改Nginx配置文件nginx.conf,增加两个server节点
#user nobody;
worker_processes ; #error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info; #pid logs/nginx.pid; events {
worker_connections ;
} http {
include mime.types;
default_type application/octet-stream; #log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"'; #access_log logs/access.log main; sendfile on;
#tcp_nopush on; #keepalive_timeout ;
keepalive_timeout ; #gzip on; server{
listen ;
server_name test1.yubay.cn; location / {
proxy_pass http://127.0.0.1:86;
index index.html index.htm;
}
} server{
listen ;
server_name test2.yubay.cn; location / {
proxy_pass http://127.0.0.1:5000;
index index.html index.htm;
}
} server {
listen ;
server_name localhost; #charset koi8-r; #access_log logs/host.access.log main; location / {
root html;
index index.html index.htm;
} #error_page /.html; # redirect server error pages to the static page /50x.html
#
error_page /50x.html;
location = /50x.html {
root html;
} # proxy the PHP scripts to Apache listening on 127.0.0.1:
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#} # pass the PHP scripts to FastCGI server listening on 127.0.0.1:
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#} # deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
} # another virtual host using mix of IP-, name-, and port-based configuration
#
#server {
# listen ;
# listen somename:;
# server_name somename alias another.alias; # location / {
# root html;
# index index.html index.htm;
# }
#} # HTTPS server
#
#server {
# listen ssl;
# server_name localhost; # ssl_certificate cert.pem;
# ssl_certificate_key cert.key; # ssl_session_cache shared:SSL:1m;
# ssl_session_timeout 5m; # ssl_ciphers HIGH:!aNULL:!MD5;
# ssl_prefer_server_ciphers on; # location / {
# root html;
# index index.html index.htm;
# }
#} }
四、启动Nginx,start nginx
浏览器访问 http://test1.yubay.cn:81 、http://test2.yubay.cn:81 会跳转到我们部署在IIS上的实际站点
五、停止nginx ,nginx -s stop
最新文章
- linux 星际词霸安装
- PCA与LDA的区别与联系
- Yocto开发笔记之《根文件系统裁剪》(QQ交流群:519230208)
- 51job前程无忧网站打不开,51job网站进不了,51job打不开
- centos 6.4 /var/log/secure 不记录日志的問題
- iOS开发——常识swift篇&;随机数获取
- 小技巧:SystemTray中进行操作提示
- 百练_4120 硬币(DP)
- yaxim
- 利用C++11的function和bind简化类创建线程
- [Swust OJ 771]--奶牛农场(几何题,画图就好)
- CCLuaObjcBridge调Objective-C方法传索引数组报invalid key to &;#39;next&;#39;错调试
- POJ 2536 Gopher II(二分图的最大匹配)
- c中的可重入和不可重入函数
- [原创]免固件开发USB2.0 FPGA方案 速度40Mbyte/s+
- spark计算两个DataFrame的差集、交集、合集
- Python并发编程
- Python3 与 C# 网络编程之~ 网络基础篇
- MySQL底层索引剖析
- Java并发编程:Java Thread方法join的简单总结
热门文章
- Base64().encodeBase64Chunked导致换行符的问题
- 02 | 日志系统:一条SQL更新语句是如何执行的?
- 【线性代数】6-4:对称矩阵(Symmetric Matrices)
- @EnableTransactionManagement的使用
- JAVA基础知识|反射
- 冲刺阶段——Day5
- GA算法及参数对结果的影响
- 网络文件共享服务—NFS服务
- fastjson序列化和反序列化报com.alibaba.fastjson.JSONException: autoType is not support异常问题,解决方案整合
- IDEA版本控制工具VCS中使用Git,以及快捷键总结(不使用命令)