linux ubuntu PHP之Nginx 配置
upstream www.xxxxxx.com {
server localhost:9041;
}
#配置80端口重定向443端口
server {
listen 80;
server_name www.xxxxxx.com;#域名
return 301 https://$server_name$request_uri;
}
server {
listen 443 ssl;
server_name www.xxxxxx.com;
ssl on; #如果强制HTTPs访问,这行要打开
ssl_certificate /ssl/1_www.xxxxxx.com_bundle.crt;
ssl_certificate_key /ssl/2_www.xxxxxx.com.key;
ssl_session_cache shared:SSL:1m;
ssl_session_timeout 5m;
# 指定密码为openssl支持的格式
ssl_protocols SSLv2 SSLv3 TLSv1.2;
ssl_ciphers HIGH:!aNULL:!MD5; # 密码加密方式
ssl_prefer_server_ciphers on; # 依赖SSLv3和TLSv1协议的服务器密码将优先于客户端密码
root /home/web/website/web;
#关键代码
location ~ .php$ {
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_pass unix:/run/php/php5.6-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
location / {
index index.php index.html;
}
location ^~ /api/ {
proxy_pass http://www.xxxxxx.com;
client_max_body_size 1024m; #允许客户端请求的最大单文件字节数,人话:能上传多大文件
client_body_buffer_size 6m; #缓冲区代理缓冲用户端请求的最大字节数,人话:一次能接受多
proxy_connect_timeout 600; #nginx跟后端服务器连接超时时间(代理连接超时),这个看需求
proxy_read_timeout 600; #连接成功后,后端服务器响应时间(代理接收超时),这个 同上
rewrite "^/api/(.*)$" /$1 break;
}
}
关键词:nginx,php,ubuntu,linux