nginx配置样例

样例1

upstream backend {

server 1**.23*.1*8.243:8065;

}

proxy_cache_path /var/cache/nginx levels=1:2 keys_zone=mattermost_cache:10m max_size=3g inactive=120m use_temp_path=off;

server {

listen 80 default_server;

server_name kenmy.club;

return 301 https://$server_name$request_uri;

}

server {

listen 443 ssl http2;

server_name    kenmy.club;

ssl on;

ssl_certificate /etc/letsencrypt/live/kenmyzhang.club/fullchain.pem;

ssl_certificate_key /etc/letsencrypt/live/kenmyzhang.club/privkey.pem;

ssl_session_timeout 5m;

ssl_protocols TLSv1 TLSv1.1 TLSv1.2;

ssl_ciphers ‘EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH‘;

ssl_prefer_server_ciphers on;

ssl_session_cache shared:SSL:10m;

location ~ /api/v[0-9]+/(users/)?websocket$ {

proxy_set_header Upgrade $http_upgrade;

proxy_set_header Connection "upgrade";

client_max_body_size 50M;

proxy_set_header Host $http_host;

proxy_set_header X-Real-IP $remote_addr;

proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

proxy_set_header X-Forwarded-Proto $scheme;

proxy_set_header X-Frame-Options SAMEORIGIN;

proxy_buffers 256 16k;

proxy_buffer_size 16k;

proxy_read_timeout 600s;

proxy_pass http://backend;

}

location / {

client_max_body_size 50M;

proxy_set_header Connection "";

proxy_set_header Host $http_host;

proxy_set_header X-Real-IP $remote_addr;

proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

proxy_set_header X-Forwarded-Proto $scheme;

proxy_set_header X-Frame-Options SAMEORIGIN;

proxy_buffers 256 16k;

proxy_buffer_size 16k;

proxy_read_timeout 600s;

proxy_cache mattermost_cache;

proxy_cache_revalidate on;

proxy_cache_min_uses 2;

proxy_cache_use_stale timeout;

proxy_cache_lock on;

proxy_pass http://backend;

}

}

样例2:

user  www www;

worker_processes  auto;

error_log /home/wwwlogs/nginx_error.log  crit;

#error_log  logs/error.log;

#error_log  logs/error.log  notice;

#error_log  logs/error.log  info;

pid        logs/nginx.pid;

worker_rlimit_nofile 51200;

events {

use epoll;

multi_accept on;

worker_connections 51200 ;

}

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;

server_names_hash_bucket_size 128;

client_header_buffer_size 32k;

large_client_header_buffers 4 32k;

client_max_body_size 500m;

sendfile        on;

tcp_nopush     on;

#keepalive_timeout  0;

keepalive_timeout  65;

fastcgi_connect_timeout 300;

fastcgi_send_timeout 300;

fastcgi_read_timeout 300;

fastcgi_buffer_size 64k;

fastcgi_buffers 4 64k;

fastcgi_busy_buffers_size 128k;

fastcgi_temp_file_write_size 256k;

gzip on;

gzip_min_length  1k;

gzip_buffers     4 16k;

gzip_http_version 1.0;

gzip_comp_level 2;

gzip_types       text/plain application/x-javascript text/css application/xml;

gzip_vary on;

gzip_proxied        expired no-cache no-store private auth;

gzip_disable        "MSIE [1-6]\.";

#limit_conn_zone $binary_remote_addr zone=perip:10m;

##If enable limit_conn_zone,add "limit_conn perip 10;" to server section.

#limit_conn_zone $binary_remote_addr zone=perip:10m;

##If enable limit_conn_zone,add "limit_conn perip 10;" to server section.

server_tokens off;

#log format

log_format  access  ‘$remote_addr - $remote_user [$time_local] "$request" ‘

‘$status $body_bytes_sent "$http_referer" ‘

‘"$http_user_agent" $http_x_forwarded_for‘;

server{

listen  80;

server_name www.example.com;

location /book/ {

proxy_pass http://127.0.0.1:3000/;

}

location /app/ {

proxy_pass http://127.0.0.1:9000/app/;

}

location /appres/ {

root /;

rewrite ^/appres/(.*)$ /home/accurme/app-res/$1 break;

}

location / {

proxy_pass http://127.0.0.1:5000/;

}

location /signup/wechat/complete {

proxy_pass http://127.0.0.1:8866/signup/wechat/complete;

}

}

server

{

listen 8887;

server_name 10*.123.*.120;

index index.html index.htm index.php default.html default.htm default.php;

root /home/wwwroot/default;

location ~ \.php($|/) {

fastcgi_pass   127.0.0.1:8999;

fastcgi_index  index.php;

fastcgi_split_path_info ^(.+\.php)(.*)$;

fastcgi_param   PATH_INFO $fastcgi_path_info;

fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;

include        fastcgi_params;

}

location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$

{

expires      30d;

}

location ~ .*\.(js|css)?$

{

expires      12h;

}

if (!-e $request_filename) {

rewrite ^/(.*)$ /index.php/$1 last;

break;

}

}

}

时间: 2024-10-09 15:09:02

nginx配置样例的相关文章

3proxy 二级代理配置样例

适应情况: 有时,我们的机器HOST-A只能通过代理服务器HOST-B才可以访问internet, 而与我们相连的机器HOST-C也需要访问internet, 但是HOST-C却不能直接访问HOST-A,此时可以以HOST-A为桥梁(二级代理服务器),让HOST-C访问internet,以下是开源3proxy做为二级代理服务器的配置样例 ###########################################################################    3

[转]3proxy 二级代理配置样例

转自:http://www.cnblogs.com/airsong23/p/3893094.html 适应情况: 有时,我们的机器HOST-A只能通过代理服务器HOST-B才可以访问internet, 而与我们相连的机器HOST-C也需要访问internet, 但是HOST-C却不能直接访问HOST-A,此时可以以HOST-A为桥梁(二级代理服务器),让HOST-C访问internet,以下是开源3proxy做为二级代理服务器的配置样例 #############################

Nginx完整配置配置样例

nginx.conf user www www; ## Default: nobody worker_processes 5; ## Default: 1 error_log logs/error.log; pid logs/nginx.pid; worker_rlimit_nofile 8192; events { worker_connections 4096; ## Default: 1024 } http { include conf/mime.types; include /etc/n

3、Nginx配置文件样例

user www-data;    #运行用户 worker_processes  4;#启动进程,通常设置成和cpu的数量相等 error_log  /var/log/nginx/error.log;#全局错误日志及PID文件 pid        /var/run/nginx.pid; #工作模式及连接数上限 events { use   epoll; #epoll是多路复用IO(I/O Multiplexing)中的一种方式,但是仅用于linux2.6以上内核,可以提高nginx的性能 w

如何实现同一交换机下广播域的隔离(VLAN)?华为交换机配置样例

华为交换机VLAN配置 VLAN的划分是在交换机的基础上建立的,怎样使交换机完成这项工作? 在探索之前,先了解网络中的两个区域: 什么是冲突域? 冲突域是与外界交互的数据必然会送达的区域.在HUB时代,HUB会将接收到某一接口的数据向所有链接它的端口,并不做选路决策,所以HUB组成的网络就是一个典型的冲突域.而在交换机之中具有更智能的选路决策功能,使得交换机一个接口下的网络是一个冲突域,所以交换机可以隔离冲突域. 什么是广播域? 在网络中的某一节点发送一个广播数据(broadcast data)

log4j(六)——log4j.properties简单配置样例说明

一:测试环境与log4j(一)--为什么要使用log4j?一样,这里不再重述 二:老规矩,先来个栗子,然后再聊聊感受 (1)使用配文件的方式,是不是感觉非常的清爽,如果不在程序中读取配置文件就更加的清爽啦!这里为了简便,就是单单使用一个Java类来做实验了. import org.apache.log4j.*; /** * Created by godtrue */ public class UseLog4j { //日志记录器 private static Logger LOGGER = Lo

log4j(七)——log4j.xml简单配置样例说明

一:测试环境与log4j(一)--为什么要使用log4j?一样,这里不再重述 二:老规矩,先来个栗子,然后再聊聊感受 (1)这里栗子有一点特别呀!给出了包名唉!想必有用,是的,配置文件中要特别说明一下的 package test.log4j.test8; import org.apache.log4j.LogManager; import org.apache.log4j.Logger; import org.apache.log4j.xml.DOMConfigurator; /** * Cre

cisco防火墙点对点VPN配置样例

需求:两端防火墙同为cisco5500系列,实现点点VPN连接,并实现nat与vpn共存 配置实例: tunnel-group 210.1.1.22 type ipsec-l2ltunnel-group 210.1.1.22 ipsec-attributes ikev1 pre-shared-key ***** (*为对方共享秘钥) crypto ipsec ikev1 transform-set VPN-B esp-3des esp-sha-hmac crypto map IPSEC_MP 1

cruisecontrol配置样例

<?xml version="1.0"?> <cruisecontrol> <project name="SampleCCProject"> <bootstrappers> <currentbuildstatusbootstrapper file="../logs/currentbuild.txt" /> <svnbootstrapper file="build-cc.x