For some questions from nginx to caddy, ask for help


(Loli Squad) #1

Nginx config

server {

proxy_max_temp_file_size 0;

fastcgi_buffers 32 8k;

client_max_body_size 500m;

client_body_buffer_size 1024k;

listen 80;

server_name admin.examples.com;

charset utf-8;

access_log /home/admin.examples.com.access.log main;

location ^~/graphql {

proxy_pass http://127.0.0.1:9002;

proxy_redirect off;

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 / {

proxy_pass http://127.0.0.1:7001;

proxy_redirect off;

proxy_set_header X-Real-IP $remote_addr;

proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

proxy_set_header Host $http_host;

proxy_set_header X-NginX-Proxy true;

}

}
How do I write this configuration if I want to use a caddy ? Can someone help me with this problem? Thank you~


(Matthew Fay) #2

Hi @LoliSquad,

This looks like two relatively straightforward transparent proxies with access logging. You should be able to achieve this with the proxy directive, note especially the transparent preset. Here’s the doc explaining how to use that:

https://caddyserver.com/docs/proxy

And for logging:

https://caddyserver.com/docs/log

If you’ve tried to write a Caddyfile and are encountering problems, feel free to post it and we can take a look.


(Loli Squad) #3

thank you for your help