(01-02) odoo8.0_Ubuntu14.04_nginx反代理设置
作者:陈伟明
联系 : QQ 942923305 | 微信 toby942923305
E-mail: cwm.win@hotmail.com
==================================
服务器
操作系统: Ubuntu trusty14.04
nginx 版本: 1.10.1
==================================
修订时间:
15:09 2015-10-20 星期二
17:13 2015-10-23 星期五 修订错误
21:45 2016-06-09 星期四
=======================安装nginx前期准备==============================
安装依赖
# apt-get -y install libpcre3 libpcre3-dev zlib1g-dev libssl-dev build-essential libxml2 libxml2-dev libxslt1.1 libxslt1-dev geoip-database libgeoip-dev freetype* libgd2-xpm-dev
新建要入下载软件的目录
# mkdir /opt/soft
# cd /opt/soft
安装openssl (做ssl 443时会用到)
# wget http://www.openssl.org/source/openssl-1.0.2d.tar.gz
# tar -zxvf openssl-1.0.2d.tar.gz -C /usr/local/src/
# cd /usr/local/src/openssl-1.0.2d/
# ./config
# make
# make install
安装nginx
==========================nginx1.10.x安装============================
# cd /opt/soft
# curl -O http://nginx.org/download/nginx-1.10.1.tar.gz
# useradd www
# mkdir -p /var/log/nginx
# chown -R www:www /var/log/nginx
# tar xzvf nginx-1.10.1.tar.gz
# cd nginx-1.10.1
# mkdir -p /var/tmp/nginx/client
# chown -R www:www /var/tmp/nginx/client
#./configure \
--prefix=/usr/local/nginx\
--conf-path=/etc/nginx/conf/nginx.conf \
--error-log-path=/var/log/nginx/error.log \
--http-log-path=/var/log/nginx/access.log \
--pid-path=/var/run/nginx/nginx.pid \
--lock-path=/var/lock/nginx.lock \
--user=www \
--group=www \
--with-openssl=/usr/local/src/openssl-1.0.2d \
--with-http_realip_module\
--with-http_sub_module \
--with-http_dav_module \
--with-http_ssl_module \
--with-http_flv_module \
--with-http_mp4_module \
--with-http_stub_status_module \
--with-http_gzip_static_module \
--with-http_image_filter_module \
--http-client-body-temp-path=/var/tmp/nginx/client/ \
--http-proxy-temp-path=/var/tmp/nginx/proxy/ \
--http-fastcgi-temp-path=/var/tmp/nginx/fcgi/ \
--http-uwsgi-temp-path=/var/tmp/nginx/uwsgi \
--http-scgi-temp-path=/var/tmp/nginx/scgi \
--with-pcre \
--with-file-aio
#make
#make install
说明:
--pid-path=/var/run/nginx/nginx.pid \
这句要和
/etc/nginx/conf/nginx.conf 中的
pid /var/run/nginx/nginx.pid;
要一样,要不然pid还是会以配置文件中的位置为标准
# vi /etc/init.d/nginx #编辑启动文件添加下面内容
-------------------------------
#!/bin/sh
### BEGIN INIT INFO
# Provides: nginx
# Required-Start: $local_fs $remote_fs $network $syslog
# Required-Stop: $local_fs $remote_fs $network $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: starts the nginx web server
# Description: starts nginx using start-stop-daemon
### END INIT INFO
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
NAME=nginx
DESC=nginx
# Include nginx defaults if available
if [ -f /etc/default/nginx ]; then
. /etc/default/nginx
fi
test -x $DAEMON || exit 0
set -e
. /lib/lsb/init-functions
test_nginx_config() {
if $DAEMON -t $DAEMON_OPTS >/dev/null 2>&1; then
return 0
else
$DAEMON -t $DAEMON_OPTS
return $?
fi
}
case "$1" in
start)
echo -n "Starting $DESC: "
test_nginx_config
# Check if the ULIMIT is set in /etc/default/nginx
if [ -n "$ULIMIT" ]; then
# Set the ulimits
ulimit $ULIMIT
fi
start-stop-daemon --start --quiet --pidfile /var/run/$NAME.pid \
--exec $DAEMON -- $DAEMON_OPTS || true
echo "$NAME."
;;
stop)
echo -n "Stopping $DESC: "
start-stop-daemon --stop --quiet --pidfile /var/run/$NAME.pid \
--exec $DAEMON || true
echo "$NAME."
;;
restart|force-reload)
echo -n "Restarting $DESC: "
start-stop-daemon --stop --quiet --pidfile \
/var/run/$NAME.pid --exec $DAEMON || true
sleep 1
test_nginx_config
# Check if the ULIMIT is set in /etc/default/nginx
if [ -n "$ULIMIT" ]; then
# Set the ulimits
ulimit $ULIMIT
fi
start-stop-daemon --start --quiet --pidfile \
/var/run/$NAME.pid --exec $DAEMON -- $DAEMON_OPTS || true
echo "$NAME."
;;
reload)
echo -n "Reloading $DESC configuration: "
test_nginx_config
start-stop-daemon --stop --signal HUP --quiet --pidfile /var/run/$NAME.pid \
--exec $DAEMON || true
echo "$NAME."
;;
configtest|testconfig)
echo -n "Testing $DESC configuration: "
if test_nginx_config; then
echo "$NAME."
else
exit $?
fi
;;
status)
status_of_proc -p /var/run/$NAME.pid "$DAEMON" nginx && exit 0 || exit $?
;;
*)
echo "Usage: $NAME {start|stop|restart|reload|force-reload|status|configtest}" >&2
exit 1
;;
esac
exit 0
-----------------------------
# chmod 775 /etc/init.d/nginx #赋予文件执行权限
# update-rc.d nginx defaults #把nginx作为服务随机器启动
# service nginx start
把nginx工具目录加入到环境变量
# vi /etc/profile 最后加一行
PATH=$PATH:/usr/local/nginx/sbin
# source /etc/profile 使其生效
------------------------------------------------------------------------------
配置nginx
# mkdir /etc/nginx/conf/conf.d/
# vi /etc/nginx/conf/nginx.conf 内容如下:
-------------------
user www;
worker_processes 4;
worker_cpu_affinity 00000001 00000010 00000011 00000100 ;
worker_rlimit_nofile 65535;
error_log /var/log/nginx/error.log; #日志
pid /var/run/nginx.pid;
events {
use epoll;
worker_connections 65535;
multi_accept on;
}
http {
include /etc/nginx/conf/mime.types;
include /etc/nginx/conf/gzip.conf;
include /etc/nginx/conf/cache-client.conf;
default_type application/octet-stream;
charset UTF-8;
index index.html index.htm ;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
types_hash_max_size 2048;
include /etc/nginx/conf/conf.d/*.conf;
}
-------------------
# vi /etc/nginx/conf/gzip.conf 内容如下:
----------------------
gzip on;
gzip_disable "msie6";
gzip_vary on;
gzip_proxied any;
gzip_comp_level 6;
gzip_min_length 1100;
gzip_buffers 16 8k;
gzip_http_version 1.1;
gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;
----------------------
# vi /etc/nginx/conf/cache-client.conf 内容如下:
----------------------
#frequently read cache
open_file_cache max=200000 inactive=20s;
open_file_cache_valid 30s;
open_file_cache_min_uses 2;
open_file_cache_errors on;
#client cache
client_max_body_size 200m;
client_body_buffer_size 128k;
client_header_buffer_size 32k;
large_client_header_buffers 4 32k;
#client timeout
sendfile on;
tcp_nopush on;
tcp_nodelay on;
server_tokens off;
----------------------
配置完成
================nginx1.10.x安装 结束===============
================配置odoo8与nginx结合 开始===============
对前odoo8 在 ubuntu14.04 是怎么安装的,可以参考前面的一篇文章 《odoo8.0 _Ubuntu14.04源码安装》
已经上传上了空间里,这里我就重复说了
前面一开始安装用的用户是www ,不是官方用的odoo ,这就为采用nginx作反代理,进行了平滑地过度。
生成ssl的证件和key
# mkdir /etc/nginx/ssl
# cd /etc/nginx/ssl
# openssl genrsa -des3 -passout pass:odoo -out server.pass.key 2048 # pass:x 可以换成 pass:hkyejian##@ 这样安全一些
# openssl rsa -passin pass:odoo -in server.pass.key -out server.key
# rm server.pass.key
# openssl req -new -key server.key -out server.csr #这里要添加相关信息,自己按提示写一下就可以
# openssl x509 -req -days 3650 -in server.csr -signkey server.key -out server.crt #指定证书的有效期 10年
到这里443 ssl 相关做好了
# vi /etc/nginx/conf/conf.d/odoo.conf 内容如下:
---------------------------------
upstream odoo8 {
server 127.0.0.1:8069 weight=1 fail_timeout=0;
}
upstream odoo8-im{
server 127.0.0.1:8072 weight=1 fail_timeout=0;
}
server {
listen 443 default;
server_name localhost;
ssl on;
ssl_certificate /etc/nginx/ssl/server.crt;
ssl_certificate_key /etc/nginx/ssl/server.key;
ssl_ciphers HIGH:!ADH:!MD5;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;
# add ssl specific settings
keepalive_timeout 60;
# increase proxy buffer to handle some Odoo web requests
proxy_buffers 16 64k;
proxy_buffer_size 128k;
underscores_in_headers on;
location / {
proxy_pass http://odoo8;
# Force timeouts if the backend dies
proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504;
# set headers
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
# Let the Odoo web service know that we're using HTTPS, otherwise
# it will generate URL using http:// and not https://
proxy_set_header X-Forwarded-Proto https;
proxy_cache_bypass $http_upgrade;
# By default, do not forward anything
proxy_buffering off;
proxy_redirect http:// https://;
proxy_headers_hash_max_size 51200;
proxy_headers_hash_bucket_size 6400;
# Set timeouts
proxy_connect_timeout 3600s;
proxy_send_timeout 3600s;
proxy_read_timeout 3600s;
send_timeout 3600s;
}
location /longpolling/ {
proxy_pass http://odoo8-im;
# Force timeouts if the backend dies
proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504;
# set headers
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
# Let the Odoo web service know that we're using HTTPS, otherwise
# it will generate URL using http:// and not https://
proxy_set_header X-Forwarded-Proto https;
proxy_cache_bypass $http_upgrade;
# By default, do not forward anything
proxy_buffering off;
proxy_redirect http:// https://;
proxy_headers_hash_max_size 51200;
proxy_headers_hash_bucket_size 6400;
# Set timeouts
proxy_connect_timeout 3600s;
proxy_send_timeout 3600s;
proxy_read_timeout 3600s;
send_timeout 3600s;
}
location ~* /web/static/ {
proxy_cache_valid 200 60m;
proxy_buffering on;
expires 864000;
proxy_pass http://odoo8;
}
access_log /log/nginx/odoo-ssl.access.log;
error_log /log/nginx/odoo-ssl.error.log;
}
server {
listen 80;
server_name localhost;
underscores_in_headers on;
add_header Strict-Transport-Security max-age=2592000;
rewrite ^/.*$ https://$host$request_uri? permanent;
error_log /log/nginx/odoo.error.log;
}
----------------------------------------------
# service nginx start
ok了,可以直接用ip访问,不要再加端口8069 ,有nginx反代理,也解了配置文件 使用workers 这个参数大于1的情况的错误
================配置odoo8与nginx结合 结束===============
(01-02) odoo8.0_Ubuntu14.04_nginx反代理设置的更多相关文章
- JMeter学习-024-JMeter 命令行(非GUI)模式详解(二)-执行代理设置
闲话少述,接 上文 继续... 5.设置代理 jmeter -n -t JMeter分布式测试示例.jmx -H 20.9.215.90 -P 9999 -l report\01-result.csv ...
- (34)odoo反代理中客户IP处理
* 前言 一般我们部署时会用nginx做为前端处理,有时负载时还会用到其它web服务反代理 这里只给出nginx处理方法,其它参考处理 * nginx上的客户IP传递 ...
- 【转】使用程序修改系统(IE)代理设置
文章都是发布在github再转到这边的,这边格式可能会乱掉.博客地址:benqy.com 这是本人在做的一个前端开发调试工具(HttpMock),功能是web服务器+http日记+http代理(类似f ...
- 9-python 的ProxyHandler处理器(代理设置)
ProxyHandler处理器(代理设置) 使用代理IP,这是爬虫/反爬虫的第二大招,通常也是最好用的. 很多网站会检测某一段时间某个IP的访问次数(通过流量统计,系统日志等),如果访问次数多的不像正 ...
- ProxyHandler处理器__代理设置__自定义opener
ProxyHandler处理器(代理设置) 使用代理IP,这是爬虫/反爬虫的第二大招,通常也是最好用的. 很多网站会检测某一段时间某个IP的访问次数(通过流量统计,系统日志等),如果访问次数多的不像正 ...
- zabbix被监控端代理设置
zabbix被监控端代理设置 安装zabbix-agent客户端 rpm -ivh https://repo.zabbix.com/zabbix/4.0/rhel/7/x86_64/zabbix-re ...
- 建站第二步:简单配置Nginx反代理工具
简单配置Nginx反代理工具 你要用你的域名能和服务器绑定就要用一些反代理工具 Nginx (engine x) 是一个高性能的HTTP和反向代理web服务器,极其优异的服务器软件,底层为C 来自某些 ...
- android sdk manager 代理设置(送给牛逼的)
解决android sdk更新慢的问题(公司竟然把sdk更新给墙了). 第一步:如下图 第二部:进入代理设置页面,进行设置.如下图
- sdk更新代理设置
sdk更新代理设置 http://www.cnblogs.com/zhoujg/p/4560998.html
随机推荐
- nginx+iis、NLB、Web Farm、Web Garden、ARR
nginx+iis实现负载均衡 在win2008R2上使用(NLB)网络负载均衡 NLB网路负载均衡管理器详解 [译文]Web Farm和Web Garden的区别? IIS负载均衡-Applicat ...
- openWrt 安装与实践
1. 先装一个编译用的环境, ubuntu 14 2. 在ubuntu里面安装svn, g++, libncurses5-dev git libssl-dev gawk, svn因为openwrt社区 ...
- vue.js实现添加删除
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- POJ-1028 Web Navigation 和TOJ 1196. Web Navigation
Standard web browsers contain features to move backward and forward among the pages recently visited ...
- 【GO】GO语言学习笔记四
流程控制 1.条件语句 举个栗子: if x>5 { return 1; }else{ return 0; } 注意: 条件语句不需要使用括号将条件包含起来(); 无论语句体内有几条语句, ...
- [课程设计]任务进度条&开发日志目录
任务进度条&开发日志目录 周期 时间 任务 Sprint One 11.14 ● Scrum团队分工及明确任务1.0 Sprint One 11.15 ● Scr ...
- 我的Android第二章
前言 之前有很多人遇到了关于内部类的问题[主要在android的学习之中会大量的使用到],内部类是什么,内部类怎么定义,内部类的分类,内部类的好处,内部类如何访问,这里我们来结合代码简单的理解一下 1 ...
- modprobe和lsmod命令配合使用
modprobe命令用于智能地向内核中加载模块或者从内核中移除模块. modprobe可载入指定的个别模块,或是载入一组相依的模块.modprobe会根据depmod所产生的相依关系,决定要载入哪些模 ...
- AngularJs开发环境搭建
1. 安装Sublime Text3 常用插件安装:AngularJs, Autoprefixer, BracketHighlighter,ConvertToUTF8,CSScomb,DocBlock ...
- OAuth2.0说明文档
OAuth2.0说明文档 1.OAuth 2.0 简介 OAuth为应用提供了一种访问受保护资源的方法.在应用访问受保护资源之前,它必须先从资源拥有者处获取授权(访问许可),然后用访问许可交换访问令牌 ...