给我一段标准的nginx配置文件代码
时间: 2023-07-16 11:17:04 浏览: 91
以下是一个简单的Nginx配置文件示例:
```
# 全局配置
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;
# 事件模块配置
events {
worker_connections 1024;
}
# HTTP模块配置
http {
# MIME类型映射
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 /var/log/nginx/access.log main;
# Gzip压缩
gzip on;
gzip_disable "msie6";
gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
# 虚拟主机配置
server {
listen 80;
server_name example.com;
root /var/www/example.com;
location / {
try_files $uri $uri/ /index.html;
}
}
}
```
这个配置文件包括全局配置,事件模块配置,HTTP模块配置和一个简单的虚拟主机配置。当然,在实际使用中,您需要根据您的需求进行修改和扩展。
阅读全文