请求转发

server {listen       8088;#server_name  localhost;#charset koi8-r;#access_log  logs/host.access.log  main;location / {#root   html;#index  index.html index.htm;proxy_pass http://www.baidu.com;}
}

说明:

  1. 通过浏览器请求 localhost:8088 地址,nginx匹配8088端口;
  2. 获取 location 下面的proxy_pass转发地址 ,转发请求至: http://www.baidu.com;

语法说明

语法规则: location [=|~|~*|^~] /uri/ { … }

= 精确匹配

^~ 以某个常规字符串开头

~ 区分大小写的正则匹配

~* 不区分大小写

/ 通用匹配,任何请求都会匹配到

配置文件


# 匹配用户
#user  nobody;
# 生成进程数量
worker_processes  1;# 生成日志存储路径
#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;# 进程文件存储位置
#pid        logs/nginx.pid;events {#设置网路连接序列化是否开启accept_mutex on;   #设置一个进程是否同时接受多个网络连接,默认为offmulti_accept on;  #事件驱动模型,select|poll|kqueue|epoll|resig|/dev/poll|eventport#use epoll; # 最多客户端连接数量worker_connections  1024;
}http {# 文件类型支持conf/mime.types文件中的类型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 方式传输文件sendfile        on;# 数据包累计后发送#tcp_nopush     on;#连接超时时间:单位秒(s)keepalive_timeout  65;# 开启数据打包#gzip  on;server {# 端口匹配listen       8088;# 请求地址匹配server_name  localhost;# 网页编码#charset koi8-r;# 指定日至文件的路径及日志格式#access_log  logs/host.access.log  main;#请求的url过滤,正则匹配,~为区分大小写,~*为不区分大小写location / {# 根目录#root   html;# 默认欢迎页面#index  index.html index.htm;# 拒绝的请求地址deny 127.0.0.1;  # 允许的请求地址allow 172.18.5.54;   }# 404异常跳转页面#error_page  404              /404.html;# redirect server error pages to the static page /50x.html# 500 502 503 504 异常跳转页面error_page   500 502 503 504  /50x.html;# 50x.html异常页面根目录location = /50x.html {root   html;}# proxy the PHP scripts to Apache listening on 127.0.0.1:80# 区分大小写匹配以.php结尾的请求#location ~ \.php$ {# 服务转发#proxy_pass   http://127.0.0.1;#}# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000# PHP服务请求配置#location ~ \.php$ {# 项目根目录#root           html;# 进程管理器服务通讯代理#fastcgi_pass   127.0.0.1:9000;# 默认访问页面#fastcgi_index  index.php;# 脚本文件请求路径#fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;# 请求参数匹配fastcgi_params文件内容指向的变量#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# 将 8082 请求转发至 proxy_pass  指向的服务server {listen       8082;#server_name  localhost;location / {#root   html;#index  index.html;proxy_pass http://www.baidu.com;}}# HTTPS server#server {#    listen       443 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 配置详解相关推荐

  1. Nginx配置详解/代理服务的配置说明

    Nginx配置详解 序言 Nginx是lgor Sysoev为俄罗斯访问量第二的rambler.ru站点设计开发的.从2004年发布至今,凭借开源的力量,已经接近成熟与完善. Nginx功能丰富,可作 ...

  2. 分布式应用Nginx配置详解

    分布式应用Nginx配置详解 Nginx基本介绍 Nginx安装 安装依赖 安装openssl 安装pcre 安装zlib 安装Nginx Nginx负载均衡 负载均衡配置 失败重试配置 Nginx限 ...

  3. 前端必备 Nginx 配置详解

    前端开发者必备的nginx知识 nginx在应用程序中的作用 解决跨域 请求过滤 配置gzip 负载均衡 静态资源服务器 nginx是一个高性能的HTTP和反向代理服务器,也是一个通用的TCP/UDP ...

  4. Nginx配置详解与示例

    Nginx配置详解 #定义Nginx运行的用户和用户组 user www www;#nginx进程数,建议设置为等于CPU总核心数. worker_processes 8;#全局错误日志定义类型,[ ...

  5. nginx配置详解,完全卸载nginx, nginx https配置

    nginx 配置文件详解 文章目录 nginx 配置文件详解 Ubuntu nginx 目录结构 nginx 配置文件结构 默认nginx.conf( (1.18.0版本) location详解,pr ...

  6. nginx配置详解,nginx跨域问题

    文章目录 前言 更改hosts文件 新增velocityerp.top.conf配置文件 nginx配置header参数(解决跨域),接口方配置 nginx反向代理(解决跨域),发送方配置 nginx ...

  7. nginx配置详解1

    Nginx 配置文件详解 user nginx ; #用户 worker_processes 8; #工作进程,根据硬件调整,大于等于cpu核数 error_log logs/nginx_error. ...

  8. JAVA开发与运维(Nginx配置详解)

    对于Nginx的使用,最重要的是理解每个配置项的作用.所以一份详细的Nginx的配置对于JAVA开发和运维尤为重要.我们一般使用两个Nginx配置文件对Nginx进行配置,一个是公共文件nginx.c ...

  9. nginx配置详解(容器、负载)—官方原版

    一.概述 本指南对nginx进行了基本介绍,并描述了一些 可以用它完成的简单任务. 据推测,nginx已经安装在阅读器的机器上. 本指南描述了如何启动和停止nginx,并重新加载其 配置,解释结构 的 ...

  10. 关于Spring Boot WebSocket整合以及nginx配置详解

    这篇文章主要给大家介绍了关于Spring Boot WebSocket整合以及nginx配置的相关资料,文中通过示例代码给大家介绍的非常详细,相信对大家的学习或者工作具有一定的参考学习价值,需要的朋友 ...

最新文章

  1. Uva(10048),最短路Floyd
  2. ajax传递多个base64,H5移动开发Ajax上传多张Base64格式图片到服务器
  3. 第27章:MongoDB-索引--唯一索引
  4. 20.if条件语句.rs
  5. mysql主从不同步问题_mysql主从之间不同步问题
  6. mqtt js 中乱码_ES6中模块导入遇到的问题及其解决办法
  7. php+flash实现转盘抽奖(加源代码)
  8. Symbol()类型的定义及特点
  9. boost基础——variant的原理及基本用法
  10. bzoj 1667: [Usaco2006 Oct]Cows on Skates滑旱冰的奶牛(BFS)
  11. centos6 安装glibc-2.14.1
  12. itx机箱尺寸_itx主机还需要显卡吗?极限尺寸s18 itx机箱装机示范
  13. 计算机不能辨别汉字wifi,电脑搜不到带汉字的wi-fi怎么办
  14. Revit开发读取CAD信息
  15. 基于随机无迹σ变异的改进HHO算法
  16. 西门子1200PLC模板通讯程序,包含多种通讯Modbus-RTU(485),S7通讯
  17. oracle客户端怎么变成中文,如何让Oracle客户端显示中文
  18. CDH集群: 数据恢复/备份
  19. 了解软件测试职业以及发展定位
  20. MATLAB——通过扫频数据反推系统伯德图

热门文章

  1. SAP HANA ANY和ALL关键字
  2. 生产订单中的下层物料信息
  3. Tablecontrol动态序号实现
  4. ABAP程序中调用不同类型的函数弹出不同的消息对话框
  5. Abap DELETE - duplicates
  6. 安卓存储性能测试软件,安卓版PCMark存储性能测试:魅族Pro 5/Pro 6都逆袭S7 edge了...
  7. h5跳转小程序页面url_web-view h5跳转到小程序页面,无法跳转?
  8. python 反转列表的3种方式
  9. Python递归算法以及命名空间
  10. 常见Python爬虫工具总结