user nginx;
worker_processes 1;
pid /var/run/nginx.pid;
# error_log /var/log/dnmp/nginx.error.log warn;
events {
worker_connections 1024;
}
http {
include /etc/nginx/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 /dev/null;
#access_log /var/log/dnmp/nginx.access.log main;
sendfile on;
#tcp_nopush on;
keepalive_timeout 65;
gzip on;
include /etc/nginx/conf.d/*.conf;
}
server {
listen 80;
# server_name localhost 0.0.0.0;
root /var/www/html/site1/api/public;
index index.php index.html index.htm;
charset utf-8;
client_max_body_size 100M;
# access_log /dev/null;
# access_log /var/log/dnmp/nginx.site1.access.log main;
# error_log /var/log/dnmp/nginx.site1.error.log warn;
#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 /usr/share/nginx/html;
}
location / {
index index.html index.php;
if (-f $request_filename/index.html){
rewrite (.*) $1/index.html break;
}
if (-f $request_filename/index.php){
rewrite (.*) $1/index.php;
}
if (!-f $request_filename){
rewrite (.*) /index.php;
}
}
# api doc
location = /apidoc {
set $my_port 4000;
if ($host = 'fanhengyuan1994.vicp.cc'){
set $my_port 13259;
}
rewrite ^/(.*) $scheme://$host:$my_port/apidoc/ redirect;
}
location = /apidoc/ {
try_files $uri $uri/ =404;
}
# deny accessing php files for the /assets directory
location ~ ^/assets/.*\.php$ {
deny all;
}
location ~ \.php$ {
fastcgi_pass php:9000;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
location ~/.well-know {
allow all;
}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
location ~ /\.ht {
deny all;
}
}