1. Caddy version (caddy version
):
Caddy 2.2.1
2. How I run Caddy:
Windows 10
a. System environment:
Windows 10
b. Command:
.\caddy_windows_amd64_custom.exe adapt --config .\nginx.conf --adapter nginx
c. Service/unit/compose file:
N/A
d. My complete Caddyfile or JSON config:
`
#D I E T - P I
# /etc/nginx/nginx.conf
user www-data;
# As a thumb rule: One per CPU.
worker_processes 4;
pid /run/nginx.pid;
# Load dynamic modules
include /etc/nginx/modules-enabled/*.conf;
# Maximum file descriptors that can be opened per process
# This should be > worker_connections
worker_rlimit_nofile 100;
events {
worker_connections 50;
}
error_log /var/log/nginx/error.log;
http {
charset utf-8;
# + Nginx - To avoid 2MB upload error: https://github.com/MichaIng/DietPi/issues/546
client_max_body_size 2047M;
# Upstream to abstract back-end connection(s) for PHP
upstream php {
server unix:/run/php/php7.3-fpm.sock;
}
# Set the mime-types via the mime.types external file
include mime.types;
# And the fallback mime-type
default_type application/octet-stream;
# Click tracking!
access_log off;
# Hide Nginx version
server_tokens off;
# ~2 seconds is often enough for HTML/CSS, but connections in
# Nginx are cheap, so generally it's safe to increase it
keepalive_timeout 2;
# You usually want to serve static files with Nginx
sendfile on;
tcp_nopush on; # off may be better for Comet/long-poll stuff
tcp_nodelay off; # on may be better for Comet/long-poll stuff
server_name_in_redirect off;
types_hash_max_size 2048;
server_names_hash_bucket_size 64;
gzip off;
gzip_http_version 1.0;
gzip_comp_level 1;
gzip_min_length 512;
gzip_buffers 4 8k;
gzip_proxied any;
gzip_types
# text/html is always compressed by HttpGzipModule
text/css
text/plain
text/x-component
application/javascript
application/json
application/xml
application/xhtml+xml
application/x-font-ttf
application/x-font-opentype
application/vnd.ms-fontobject
image/svg+xml
image/x-icon;
# This should be turned on if you are going to have pre-compressed copies (.gz) of
# static files available. If not it should be left off as it will cause extra I/O
# for the check. It would be better to enable this in a location {} block for
# a specific directory:
#gzip_static on;
gzip_disable "msie6";
gzip_vary on;
#security options applies to all sites
add_header X-Frame-Options "SAMEORIGIN";
add_header X-XSS-Protection "1;mode=block";
add_header Feature-Policy "geolocation none;midi none;notifications none;push none;sync-xhr none;microphone none;camera none;magnetometer none;gyroscope none;speaker self;vibrate none;fullscreen self;payment none;";
######### for wordpress
map $uri $blogname{
~^(?P<blogpath>/[^/]+/)files/(.*) $blogpath ;
}
map $blogname $blogid{
default -999;
}
#########
#####a#####
server {
ssl_certificate /etc/nginx/ssl/cert.pem;
ssl_certificate_key /etc/nginx/ssl/key.pem;
ssl_client_certificate /etc/nginx/ssl/origin-pull-ca.pem;
ssl_verify_client on;
# root /var/www/a/ftp_tmp;
root /var/www/a;
server_name www.a.com;
listen 443 ssl http2;
keepalive_timeout 70;
index index.php;
location ~ \.php$ {
fastcgi_pass unix:/var/run/php/php7.3-fpm.sock;
fastcgi_index index.php;
include /etc/nginx/fastcgi_params;
access_log /var/log/nginx/a/main.access.log;
error_log /var/log/nginx/a/main.error.log;
fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
fastcgi_param REQUEST_URI $request_uri;
fastcgi_param DOCUMENT_URI $document_uri;
fastcgi_param DOCUMENT_ROOT $document_root;
fastcgi_param SERVER_PROTOCOL $server_protocol;
fastcgi_param REMOTE_ADDR $remote_addr;
fastcgi_param REMOTE_PORT $remote_port;
fastcgi_param SERVER_ADDR $server_addr;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_NAME $server_name;
}
}
###### b#####
server {
ssl_certificate /etc/nginx/ssl/cert2.pem;
ssl_certificate_key /etc/nginx/ssl/key2.pem;
ssl_client_certificate /etc/nginx/ssl/origin-pull-ca.pem;
ssl_verify_client on;
root /var/www/b;
server_name b.com ;
listen 443 ssl http2;
keepalive_timeout 70;
access_log /var/log/nginx/b/main.access.log;
error_log /var/log/nginx/b/main.error.log;
}
###### c#####
server {
ssl_certificate /etc/nginx/ssl/cert3.pem;
ssl_certificate_key /etc/nginx/ssl/key3.pem;
ssl_client_certificate /etc/nginx/ssl/origin-pull-ca.pem;
ssl_verify_client on;
keepalive_timeout 70;
access_log /var/log/nginx/c.log;
error_log /var/log/nginx/c.log;
listen 443 ssl http2;
server_name c.com;
root /var/www/c;
index index.php;
location ~ ^(/[^/]+/)?files/(.+) {
try_files /wp-content/blogs.dir/$blogid/files/$2 /wp-includes/ms-files.php?file=$2 ;
access_log off; log_not_found off; expires max;
}
#avoid php readfile()
location ^~ /blogs.dir {
internal;
alias /var/www/c/wp-content/blogs.dir ;
access_log off; log_not_found off; expires max;
}
if (!-e $request_filename) {
rewrite /wp-admin$ $scheme://$host$request_uri/ permanent;
rewrite ^(/[^/]+)?(/wp-.*) $2 last;
rewrite ^(/[^/]+)?(/.*\.php) $2 last;
}
location / {
try_files $uri $uri/ /index.php?$args ;
}
location ~ \.php$ {
try_files $uri =404;
include fastcgi_params;
fastcgi_pass unix:/var/run/php/php7.3-fpm.sock;
fastcgi_param HTTPS on;
fastcgi_index index.php;
include fastcgi.conf;
}
}
#####d#######
server {
ssl_certificate /etc/nginx/ssl/cert4.pem;
ssl_certificate_key /etc/nginx/ssl/key4.pem;
ssl_client_certificate /etc/nginx/ssl/origin-pull-ca.pem;
ssl_verify_client on;
root /var/www/d;
server_name d.com;
listen 443 ssl http2;
keepalive_timeout 70;
index index.php;
access_log /var/log/nginx/d/main.access.log;
error_log /var/log/nginx/d/main.error.log;
location ~ ^(/[^/]+/)?files/(.+) {
try_files /wp-content/blogs.dir/$blogid/files/$2 /wp-includes/ms-files.php?file=$2 ;
access_log off; log_not_found off; expires max;
}
#avoid php readfile()
location ^~ /blogs.dir {
internal;
alias /var/www/d/wp-content/blogs.dir ;
access_log off; log_not_found off; expires max;
}
if (!-e $request_filename) {
rewrite /wp-admin$ $scheme://$host$request_uri/ permanent;
rewrite ^(/[^/]+)?(/wp-.*) $2 last;
rewrite ^(/[^/]+)?(/.*\.php) $2 last;
}
location / {
try_files $uri $uri/ /index.php?$args ;
}
location ~ \.php$ {
try_files $uri =404;
include fastcgi_params;
fastcgi_pass unix:/var/run/php/php7.3-fpm.sock;
fastcgi_param HTTPS on;
fastcgi_index index.php;
include fastcgi.conf;
}
}
#####e#####
server {
ssl_certificate /etc/nginx/ssl/cert5.pem;
ssl_certificate_key /etc/nginx/ssl/key5.pem;
ssl_client_certificate /etc/nginx/ssl/origin-pull-ca.pem;
ssl_verify_client on;
root /var/www/e;
server_name e.com;
listen 443 ssl http2;
keepalive_timeout 70;
index index.html;
access_log /var/log/nginx/e/access.log;
error_log /var/log/nginx/e/error.log;
location ~ \.(jpg|jpeg|gif|png|css|js|ico|svg|eot|ttf|woff|woff2|otf)$ {
access_log off;
expires 30d;
}
location ~ \.php$ {
fastcgi_pass unix:/var/run/php/php7.3-fpm.sock;
fastcgi_index index.php;
include fastcgi.conf;
fastcgi_param HTTPS on;
}
location / {
try_files $uri $uri/ /index.php?$args;
}
location ^~ /bl-content/databases/ { deny all; }
location ^~ /bl-content/workspaces/ { deny all; }
location ^~ /bl-content/pages/ { deny all; }
location ^~ /bl-kernel/*.php { deny all; }
}
######f########
server {
ssl_certificate /etc/nginx/ssl/cert6.pem;
ssl_certificate_key /etc/nginx/ssl/key6.pem;
ssl_client_certificate /etc/nginx/ssl/origin-pull-ca.pem;
ssl_verify_client on;
listen 443 ssl http2;
keepalive_timeout 70;
server_name f.com;
autoindex off;
client_max_body_size 15M;
client_body_buffer_size 128k;
index doku.php;
access_log /var/log/nginx/f/wiki.access.log;
error_log /var/log/nginx/f/wiki.error.log;
root /var/www/f;
location / {
try_files $uri $uri/ @dokuwiki;
}
location ~ ^/lib.*\.(gif|png|ico|jpg)$ {
expires 30d;
}
location = /robots.txt { access_log off; log_not_found off; }
location = /favicon.ico { access_log off; log_not_found off; }
location ~ /\. { access_log off; log_not_found off; deny all; }
location ~ ~$ { access_log off; log_not_found off; deny all; }
location @dokuwiki {
rewrite ^/_media/(.*) /lib/exe/fetch.php?media=$1 last;
rewrite ^/_detail/(.*) /lib/exe/detail.php?media=$1 last;
rewrite ^/_export/([^/]+)/(.*) /doku.php?do=export_$1&id=$2 last;
rewrite ^/(.*) /doku.php?id=$1 last;
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_pass unix:/var/run/php/php7.3-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include /etc/nginx/fastcgi_params;
fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_intercept_errors on;
fastcgi_ignore_client_abort off;
fastcgi_connect_timeout 60;
fastcgi_send_timeout 180;
fastcgi_read_timeout 180;
fastcgi_buffer_size 128k;
fastcgi_buffers 4 256k;
fastcgi_busy_buffers_size 256k;
fastcgi_temp_file_write_size 256k;
}
location ~ /(data|conf|bin|inc)/ {
deny all;
}
location ~ /\.ht {
deny all;
}
}
########Pi-Hole########
server {
listen 80 default_server;
listen [::]:80 default_server;
root /var/www/html;
server_name _;
autoindex off;
index pihole/index.php index.php index.html index.htm;
location / {
expires max;
try_files $uri $uri/ =404;
}
location ~ \.php$ {
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root/$fastcgi_script_name;
fastcgi_pass unix:/run/php/php7.3-fpm.sock;
fastcgi_param FQDN true;
}
location /*.js {
index pihole/index.js;
#auth_basic "PiHole Admin"; # For Basic Auth
#auth_basic_user_file /etc/nginx/.htpasswd; # For Basic Auth
}
location /admin {
root /var/www/html;
index index.php index.html index.htm;
#auth_basic "PiHole Admin"; # For Basic Auth
#auth_basic_user_file /etc/nginx/.htpasswd; # For Basic Auth
}
location ~ /\.ht {
deny all;
}
}
####new website####
###xxxxxxx####end of http tag below, all above this####xxxxxxx###
}
`
3. The problem I’m having:
I am trying to convert my nginx.conf to caddy json
4. Error messages and/or full log output:
adapt: parsing: Could not import \etc\nginx\mime.types: open \etc\nginx\mime.types: The system cannot find the path specified.
5. What I already tried:
I attempted to try on linux but could not figure it out so tried the windows version with the nginx-adapter ticket and got the above error, I assume this is because the adapter is hard coded for linux only