Nginx.conf path configuration specification under win
Article directory
Win absolute path can be used
There is a saying on the Internet that Nginx cannot set an absolute path under win, but I successfully set it under Nginx-1.24.0.
The path cannot contain Chinese
If you use: C:\软件\Nginx
path, nginx will report an error that the file cannot be found.
Path cannot contain spaces
If you use: C:\Program Files\Nginx
path, nginx will report an error that the file cannot be found. unless changed to:C:\ProgramFiles\Nginx
"\n" in the path will be recognized as a newline
If you use: C:\nginx
path, nginx will report an error that the file cannot be found. The reason is that nginx will \n
recognize it as a newline, and the final path is recognized as:
C:
ginx
The correct way of writing is: C:\\nginx
. We can always use double slashes \\
instead of single slashes\
For example, the error_log configuration is as follows:
nginx will report an error:
Paste a correctly configured Nginx.conf code
worker_processes 1;
error_log D:\\nginx\\logs\\error.log info;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
server {
listen 80;
server_name localhost;
location / {
root html;
index index.html index.htm;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
server {
#监听443端口
listen 443 ssl;
server_name 127.0.0.1;
#ssl证书的crt文件路径
ssl_certificate D:\\SSLCertificate\\server.crt;
#ssl证书的key文件路径
ssl_certificate_key D:\\SSLCertificate\\server.key;
location / {
root html;
index index.html index.htm;
proxy_pass http://127.0.0.1:7001;
}
}
}