2014年1月3日 13:52:07

喜欢这样的风格,干货

http://huoding.com/2013/10/23/290

-----------------下边是我自己的经验(windows)-----------------------

启动nginx

f:/nginxserver/nginx/nginx.exe -c f:/nginxserver/nginx/conf/nginx.conf

在windows下启动nginx要在命令行里进入nginx.exe的那个目录里,否则会提示不能创建日志文件(不能简单的改写环境变量)

nginx: [alert] could not open error log file: CreateFile() "logs/error.log" failed (: The system cannot find the path specified)

如果域名比较多的话,在http配置块里添加指令:server_names_hash_bucket_size 64;

nginx: [emerg] could not build the server_names_hash, you should increase server_names_hash_bucket_size: 

如果server 配置块儿中的字符集配置指令如果和默认的冲突了,那就会被忽略掉(我设置为utf8,的冲突了)

 nginx: [warn] conflicting server name "charset" on 0.0.0.0:, ignored
nginx: [warn] conflicting server name "utf8" on 0.0.0.0:, ignored

server 块中可以指定日志路径和日志格式,如果指定了日志格式(这里是main),就得保证这个日志格式在http块儿中已经被声明定义了

nginx: [emerg] unknown log format "main" in F:\vc9server\nginx\conf\apache.conf:

如果全局中已经定义了日志配置指令,则虚拟机中的会被忽略

nginx: [warn] conflicting server name "access_log" on 0.0.0.0:, ignored

http块儿中的日志格式定义(main为格式名字, 后边的字符串是具体格式)

 log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';

终止nginx

taskkill /F /IM nginx.exe > nul

2019-6-5 10:08:58 星期三

windows 启动脚本:

 @echo off

 rem 启动进程前杀掉已有进程
taskkill /f /im nginx.exe set currentDir=%cd%
cd %currentDir%
cd nginx nginx.exe -v
echo.
echo Start Nginx
rem nginx.exe -c ./conf/nginx.conf -p %currentDir%
nginx.exe -c ./conf/nginx.conf pause

2019-6-5 9:59:53 星期三

反向代理

 ### http段配置
upstream php56 {
#ip_hash;
server 127.0.0.1:8061;
server 127.0.0.1:8062;
server 127.0.0.1:8063;
server 127.0.0.1:8064;
server 127.0.0.1:8065; } server {
listen 80;
server_name www.proxy.com ;
location / {
proxy_pass_header Server;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Scheme $scheme;
proxy_pass http://php56;
}
} server {
listen 8061;
server_name www.proxy.com; location ~ \.php$ {
root D:\server\code;
fastcgi_buffer_size 512k;
fastcgi_buffers 32 128k;
fastcgi_pass 127.0.0.1:9561;
fastcgi_read_timeout 239;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
#fastcgi_param SCRIPT_FILENAME
include fastcgi_params;
} } server {
listen 8062;
server_name www.proxy.com; location ~ \.php$ {
root D:\server\code;
fastcgi_buffer_size 512k;
fastcgi_buffers 32 128k;
fastcgi_pass 127.0.0.1:9562;
fastcgi_read_timeout 239;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
#fastcgi_param SCRIPT_FILENAME
include fastcgi_params;
} } server {
listen 8063;
server_name www.proxy.com; location ~ \.php$ {
root D:\server\code;
fastcgi_buffer_size 512k;
fastcgi_buffers 32 128k;
fastcgi_pass 127.0.0.1:9563;
fastcgi_read_timeout 239;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
#fastcgi_param SCRIPT_FILENAME
include fastcgi_params;
} } ###php 测试代码 echo '<pre>'; print_r($_SERVER);
//先启动多个PHP进程(php-cgi.exe), 监听多个不同的端口(如上的 9561, 9562...), 修改hosts添加 127.0.0.1 www.proxy.com; 然后浏览器访问 wwww.proxy.com, 多次刷新, 观察打印出来的服务端端口的变化

nginx配置, 启动命令, 反向代理配置的更多相关文章

  1. Nginx或Apache通过反向代理配置wss服务

    nginx配置参考 前提条件及准备工作: 1.假设ws服务监听的是8282端口(websocket协议) 2.已经申请了证书(pem/crt文件及key文件)放在了/etc/nginx/conf.d/ ...

  2. apache 反向代理配置(ubuntu)

    1.配置apache2的站点文件 cd /etc/apache2/site-avaliable sudo vim edy.conf 具体配置如下: # 反向代理配置 # 监听所有80端口的访问 < ...

  3. Nginx 部署、反向代理配置、负载均衡

    Nginx 部署.反向代理配置.负载均衡 最近我们的angular项目部署,我们采用的的是Nginx,下面对Nginx做一个简单的介绍. 为什么选择Nginx 轻:相比于Apache,同样的web服务 ...

  4. nginx反向代理配置及优化

    nginx反向代理配置及优化前言: 由于服务器apache抗不住目前的并发.加上前端squid配置后,问题依然无法解决.而页面程序大部分是动态.无法使用fastcgi来处理.因此想使用nginx做为反 ...

  5. Nginx插件之openresty反向代理和日志滚动配置案例

    Nginx插件之openresty反向代理和日志滚动配置案例 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 一.openresty介绍 1>.Nginx介绍 Nginx是一款 ...

  6. Nginx总结(五)如何配置nginx和tomcat实现反向代理

    前面讲了如何配置Nginx虚拟主机,大家可以去这里看看nginx系列文章:https://www.cnblogs.com/zhangweizhong/category/1529997.html 今天要 ...

  7. 如何配置nginx和tomcat实现反向代理?

    什么是反向代理         通常的代理服务器,只用于代理内部网络对Internet的连接请求,客户机必须指定代理服务器,并将本来要直接发送到Web服务器上的http请求发送到代理服务器中由代理服务 ...

  8. nginx反向代理配置

    最近在项目中使用nginx反向代理,根据不同的请求路径,将请求分发到不同服务.下面的示例主要完成如下功能 /prod/路径的请求分发到prod服务 /test/路径的请求分发到test服务 创建文件夹 ...

  9. nginx反向代理配置实例分享

    nginx反向代理配置一例. 配置内容如下: user www www; worker_processes 8; error_log /usr/local/webserver/nginx/logs/n ...

随机推荐

  1. Linux基础篇之FTP服务器搭建(一)

    一.配置网络可以访问互联网(没有条件的可以提前下载相关版本的依赖包(也叫安装包,以下统称依赖包)上传到系统中也可以). 二.检查系统中是否存在相关的依赖包. 没有返回信息,说明系统中不存在相关的依赖包 ...

  2. winfrom 自动关闭 重新MessageBox.Show("Test");

    复制代码  自动关闭 调用    AutoClosingMessageBox.Show("添加失败", "提示", 1000); #region alert p ...

  3. macOS 终端常用命令

    macOS 常用命令 基本命令 1.列出文件 ls 参数 目录名 例:看看驱动目录下有什么:ls /System/Library/Extensions 参数 -w 显示中文,-l 详细信息,-a 包括 ...

  4. celery+django+mq 异步任务与定时任务

    参考 celerypip install celery==4.1.1https://www.cnblogs.com/wdliu/p/9530219.htmlhttps://www.jianshu.co ...

  5. import this: python原则

    >>> import this The Zen of Python, by Tim Peters Beautiful is better than ugly. Explicit is ...

  6. 【pip】使用

    错误及解决 install 1.pip install aip 报错[Windows,python3.6] ERROR: Could not find a version that satisfies ...

  7. MyBatis-08-使用注解开发

    8.使用注解开发 8.1.面向接口编程 面向接口编程的根本原因:解耦,可拓展,提高复用,分层开发中.上层不用管具体的实现,大家都遵守共同的标准,使得开发变得容易,规范性好 8.2.使用注解开发 注解在 ...

  8. ios的uc浏览器图片加载不出来原因

    最近做一个落地页发现一个在ios设备上uc浏览器的bug 在uc浏览器开启广告过滤的时候,会把图片过滤掉,无论是背景图还是img标签加载的图片 经过搜索与实验,发现广告过滤的设置关掉就可以,可是一般情 ...

  9. mysql批量新增和批量删除

    首先推荐使用PreparedStatement的批量处理操作. Connection conn = null; PreparedStatement stmt = null; try{ Class.fo ...

  10. [转]vue解决刷新页面vuex数据、params参数消失的问题

    一般项目都会有一些逻辑需要传递值给另一个页面,那么有的时候就会出现一个问题:用户刷新了页面,诶?数据没了,参数错误.那么今天经过总结,解决了这个问题.我在最新的项目中,通过了一下几种情况进行传值: 1 ...