#user nobody;
worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
events {
worker_connections 1024;
}
http {
include 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 logs/access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#gzip on;
# HTTPS server
# 监听https的默认443端口
server {
listen 443 ssl;
server_name 域名;
ssl_certificate cert.pem; #crt文件
ssl_certificate_key cert.key; #key文件
ssl_session_timeout 5m;
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;
location / {
root html;
index index.html index.htm;
}
}
# 监听80端口
server {
listen 80;
server_name localhost;
#charset koi8-r;
#access_log logs/host.access.log main;
#添加的图片上传的模块(整个模块)
location ~ .*\.(gif|jpg|jpeg|png)$ {
expires 24h;
root E:/aaa;#指定图片存放路径
access_log E:/log;#图片路径
proxy_store on;
proxy_store_access user:rw group:rw all:rw;
proxy_temp_path E:/aaa;#图片路径
proxy_redirect off;
proxy_set_header Host 127.0.0.1;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
client_max_body_size 10m;
client_body_buffer_size 1280k;
proxy_connect_timeout 900;
proxy_send_timeout 900;
proxy_read_timeout 900;
proxy_buffer_size 40k;
proxy_buffers 40 320k;
proxy_busy_buffers_size 640k;
proxy_temp_file_write_size 640k;
if ( !-e $request_filename)
{
proxy_pass https://ip或域名; #代理访问地址 ip为服务器的公网ip或域名
}
}
location / {
root E:/路径/;
autoindex on;
add_header Access-Control-Allow-Origin *; #是否允许跨域
add_header Cache-Control "no-cache,must-revalidate"; # 是否缓存
index index.html index.htm static;
}
# 代理到服务
location /client/ {
proxy_pass http://127.0.0.1:8071/;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
# 静态资源
location /images/ {
root E:/路径/;
autoindex on;
}
#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;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
location ~ \.mp4$ { #如果需访问教学视频等需配置视频路径
root E:/project/staticSource/;#指定视频存放路径
access_log E:/project/staticSource/video/log;#日志路径
}
# 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;
# }
#}
}
window环境下如何配置nginx代理
最新推荐文章于 2024-07-20 15:21:43 发布
该博客详细介绍了如何配置Nginx以支持HTTPS服务,并设置图片上传代理。通过设置多个location块,实现了静态资源的管理、跨域访问控制以及视频路径的配置。同时,对SSL证书、连接超时、缓存策略等关键参数进行了配置。
摘要由CSDN通过智能技术生成