向往未来,缅怀过去,不知不觉又来到了下班年。往日依旧,大环境一如既往的经济萧条,所有的人都在忙碌,都在期待这忙碌之后的收获。我不会忘记去又怕忘记这陪伴我已久一段服务器配置,他陪伴了我多少个日日夜夜,让我一次又一次的解决了客户网站服务器的难题,我把这段服务器的配置展示分享一下
nginx.conf
user 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 65535;
multi_accept on;
}
http {
include mime.types;
default_type application/octet-stream;
server_tokens off;
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 65;
client_max_body_size 100m;
gzip on;
gzip_min_length 1k;
gzip_comp_level 4;
gzip_types text/plain application/x-javascript application/javascript text/css application/xml text/javascript application/x-httpd-php image/jpeg image/gif image/png;
gzip_vary off;
server {
listen 80;
server_name _;
if ($host = "jxq.coastal-datatech.com"){
rewrite ^(.*)$ https://$host$1 permanent;
}
#charset koi8-r;
#access_log logs/host.access.log main;
#location / {
# root html;
# index index.html index.htm;
#}
#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;
}
location / {
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header request-uri $request_uri;
proxy_pass http://app;
}
# 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;
# }
#}
upstream app {
#ip_hash;
server 127.0.0.1:8081;
#server 172.23.7.173:8081;
#server 172.23.7.171:8081;
#server 127.0.0.1:8081;
keepalive 64;
}
include vhost/*.conf;
}
nginx.conf
#jxq.coastal-datatech.com
server {
listen 8081; #443 ssl; #删掉 ssl on; 配置项 ssl写在443端口后面
#server_name jxq.coastal-datatech.com;
server_name 127.0.0.1;
#ssl_certificate vhost/ssl/_en.coastal-datatech.com.pem;
#ssl_certificate_key vhost/ssl/_en.coastal-datatech.com.key;
#让http请求重定向到https请求
#error_page 497 https://$host$uri?$args;
#ssl_session_cache shared:SSL:1m;
#ssl_session_timeout 5m;
#ssl_ciphers HIGH:!aNULL:!MD5;
#ssl_prefer_server_ciphers on;
error_page 404 /index.html;
location / {
root /www/jxq.coastal-datatech.com/public;
index index.html index.htm;
if ($request_uri ~* "\.(gif|jpg|jpeg|png|bmp|swf|css|js|ttf|json)") {
#expires 15d;
break;
}
if ($request_uri ~* "robots\.txt") {
#expires 15d;
break;
}
if (!-e $request_filename) {
rewrite ^(.*)$ /index.php?s=/$1 last;
break;
}
client_max_body_size 1000M;
}
location ~ \.php$ {
root /www/jxq.coastal-datatech.com/public;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
#下面两句是给fastcgi权限,可以支持 ?s=/module/controller/action的url访问模式
fastcgi_split_path_info ^((?U).+\.php)(/?.+)$;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
#下面两句才能真正支持 index.php/index/index/index的pathinfo模式
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
include fastcgi_params;
}
}