nginx配置文件(1)

user  root;
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 {
    worker_connections  1024;
}

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  0;
    keepalive_timeout  65;

    #gzip  on;

    server {
        listen       80;
        server_name  192.168.124.200 

;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        # ?2ì?ò3??????
		root       /www/dist;
		# ??è?ê×ò3
        index      index.html;
		location / {
			# ó??§?ˉàà?÷??μ??o′?éè??
			location ~ .*\.(jpg|jpeg|gif|png|swf|htm|html|json|xml|svg|woff|ttf|eot|map|ico)$ {
				expires 10d;
			}
			location ~ .*\.(js|css)?$ {
				expires 1h;
			}
			location ~* \.(css|js|jpg|jpeg|gif|png|swf|htm|html|json|xml|svg|woff|ttf|eot|map|ico)$ {
				if (-f $request_filename) {
						break;
				}
			}
			# ?ˉì?ò3??,????tomcat′|àí
			if ( !-e $request_filename) {
				proxy_pass http://192.168.124.200:8040 

;
			}
		}
		location /fileUpload {
			# ó??§?ˉàà?÷??μ??o′?éè??
			location ~ .*\.(jpg|jpeg|gif|png|swf|htm|html|json|xml|svg|woff|ttf|eot|map|ico)$ {
				expires 10d;
			}
			location ~ .*\.(js|css)?$ {
				expires 1h;
			}
			location ~* \.(css|js|jpg|jpeg|gif|png|swf|htm|html|json|xml|svg|woff|ttf|eot|map|ico)$ {
				if (-f $request_filename) {
						break;
				}
			}
			# ?ˉì?ò3??,????tomcat′|àí
			if ( !-e $request_filename) {
				proxy_pass http://124.206.192.194:8088 

;
			}
		}
        #error_page  404              /404.html;

        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }

        # proxy the PHP scripts to Apache listening on 127.0.0.1:80
        #
        #location ~ \.php$ {
        #    proxy_pass   http://127.0.0.1;
        #}

        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #
        #location ~ \.php$ {
        #    root           html;
        #    fastcgi_pass   127.0.0.1:9000;
        #    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       8000;
    #    listen       somename:8080;
    #    server_name  somename  alias  another.alias;

    #    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}

    # 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;
    #    }
    #}

}

  

时间: 2024-08-27 22:16:56

nginx配置文件(1)的相关文章

linux下Nginx配置文件(nginx.conf)配置设置详解(windows用phpstudy集成)

linux备份nginx.conf文件举例: cp /usr/local/nginx/nginx.conf /usr/local/nginx/nginx.conf-20171111(日期) 在进程列表里 面找master进程,它的编号就是主进程号. ps -ef | grep nginx 查看进程 cat /usr/local/nginx/nginx.pid 每次修改完nginx文件都要重新加载配置文件linux命令: /usr/local/nginx -t //验证配置文件是否合法 若ngin

nginx配置文件详解

nginx配置文件nginx.conf超详细讲解 #nginx进程,一般设置为和cpu核数一样worker_processes 4;                        #错误日志存放目录 error_log  /data1/logs/error.log  crit;  #运行用户,默认即是nginx,可不设置user nginx       #进程pid存放位置pid        /application/nginx/nginx.pid; #Specifies the value

ansible管理nginx配置文件

#生产环境中大多时候是需要管理配置文件的,安装软件包只是在初始化环境的时候用一下.下面我们来写个管理nginx配置文件的playbook 一.创建相关目录 mkdir  -p /etc/ansible/nginx_config/roles/{new,old}/{files,handlers,vars,tasks} #其中new为更新时用到的,old为回滚时用到的,files下面为nginx.conf和vhosts目录,handlers为重启nginx服务的命令. #关于回滚,需要在执行playb

nginx 配置文件 PATHINFO重写规则

user  www www;worker_processes  2; #error_log  logs/error.log;#error_log  logs/error.log  notice;#error_log  logs/error.log  info; pid        logs/nginx.pid; events {    use epoll;    worker_connections  2048;} http {    include       mime.types;   

NGINX配置文件nginx.conf详解

1.配置文件结构 Nginx配置文件主要分成四部分:main(全局设置).server(主机设置).upstream(上游服务器设置,主要为反向代理.负载均衡相关配置)和 location(URL匹配特定位置后的设置),每部分包含若干个指令.main部分设置的指令将影响其它所有部分的设置:server部分的指令主要用于指定虚拟主机域名.IP和端口:upstream的指令用于设置一系列的后端服务器,设置反向代理及后端服务器的负载均衡:location部分用于匹配网页位置(比如,根目录"/"

ansible-管理nginx配置文件

背景:安装软件包,只是在初始化环境时用一下,大多时候需要修改配置文件:管理Nginx配置文件的playbook,执行playbook之前,一定要备份旧的配置:机器上的配置文件需和new/files保持一致 1. 创建目录和配置文件 说明:new为更新时用到,old为回滚时用到,即将new目录内容拷贝进来 mkdir -p /etc/anxible/nginx_config/roles/new/{files,handlers,vars,tasks} mkdir -p /etc/anxible/ng

配置使用vim编辑Nginx配置文件时语法高亮

vim是Unix系统中非常实用的文本编辑器,它和传统的vi相比最大的区别在于它所支持的配色方案,这个功能使得平时编辑一些配置文件或者是在写代码的时候极大的提高工作效率,如果我们在系统中有安装vim相应的包且开启了syntax配色方案的时候会不显示语法高亮往往是配置设置错误所引起的.一般配置错误有2个地方:1.是远程服务器的仿真客户终端配置错误:2.是服务器上环境变量配置错误.在这里就用SecureCRT仿真客户终端为例子简单的说一下vim开启syntax配色方案: 在SecureCRT上需要配置

【Nginx笔记】nginx配置文件具体解释

本文主要对nginx的配置做重点说明,关于nginx的其他基本概念.建议參考官网描写叙述.这里推荐Nginx Beginner's Guide这篇文档.对刚開始学习的人高速认识nginx非常有帮助. 显然.发挥nginx强大优势的前提是熟悉其配置文件并进行合理的配置.而学习nginx配置时.最重要的一点是建立例如以下概念: The most important is that nginx is a reverse proxy first and HTTP server second, its f

Nginx配置文件详细说明

Nginx服务器nginx.conf的配置文件说明, 部分注释收集与网络. #运行用户user www-data;    #启动进程,通常设置成和cpu的数量相等worker_processes  1; #全局错误日志及PID文件error_log  /var/log/nginx/error.log;pid        /var/run/nginx.pid; #工作模式及连接数上限events {    use   epoll;             #epoll是多路复用IO(I/O Mu

etcd+confd实现Nginx配置文件自动管理

一.需求 我们使用Nginx做七层负载均衡,后端是Tomcat.项目采用灰度发布方式,每次项目升级,都要手动先从Nginx下摘掉一组,然后再升级这组,当项目快速迭代时,手动做这些操作显然会增加部署时间,于是就想通过脚本实现自动化管理Nginx配置文件. 当时考虑自己写Shell脚本对Nginx配置文件操作,需要用到sed流编辑器,sed本身没有条件判断语句,并不能灵活判断配置文件中要添加/删除位置,因此会增加配置错误风险. 在查资料无意间发现confd能自动管理配置文件,通过模板渲染生成配置文件