I have a config file for Caddy v2 like in below:
sentry.mydomain.ru {
reverse_proxy sentry:9000
}
tasks.mydomain.ru {
reverse_proxy taiga-proxy:80
}
ain.mydomain.ru {
reverse_proxy ain-frontend:80
}
Caddy makes https for every domain but I need to make disable "https" only for ain.mydomain.ru.
How to do it?
Caddy serves http traffic only if you prefix the domain with http scheme.
Here is the modified Caddyfile:
sentry.mydomain.ru {
reverse_proxy sentry:9000
}
tasks.mydomain.ru {
reverse_proxy taiga-proxy:80
}
http://ain.mydomain.ru {
reverse_proxy ain-frontend:80
}
Reference: https://caddy.community/t/is-there-any-way-to-disable-tls-from-the-caddyfile/8372/2
domain:80 or ip:80 will help you access your site on http mode. The example below ain.mydomain.ru will be available only on http. Also ensure tls directive is disabled for the domains you want to access via port 80 using http protocol only.
sentry.mydomain.ru {
reverse_proxy sentry:9000
}
tasks.mydomain.ru {
reverse_proxy taiga-proxy:80
}
ain.mydomain.ru:80 {
reverse_proxy ain-frontend:80
}
Related
My Caddy config does not redirect https://example.com to https://www.example.com
However, if I just type http://example.com, it does the redirection correctly to https://www.example.com
Caddy file:
{
debug
email myemail#example.com
}
example.com {
redir https://www.example.com{uri}
}
www.example.com {
tls {
on_demand
}
reverse_proxy docker:7000
}
I'm trying to do something which seems fairly trivial to me, but can't seem to get it right with Caddy.
I have the following site configured with Caddy:
foo.com {
tls {
dns cloudflare ...
}
reverse_proxy /* http://proxy-foo
}
I'm now trying to enable a maintenance page, such that all requests serve the maintenance html, and return a 503 status code. But, I can either serve the page, or the status code, but not both.
I first tried the handle_errors directive, with a respond directive
foo.com {
tls {
dns cloudflare ...
}
# reverse_proxy /* http://proxy-foo
handle_errors {
rewrite * /503.html
file_server
}
respond * 503
}
only to later read the caveat that respond doesn't trigger the error handlers.
Also tried removing all other directives, thinking that would trigger a 404, which would in turn call the handle_errors block, but that too doesn't work. It just ends up returning 200, but with no body.
Any pointers as to where I'm going wrong much appreciated.
You can try configure reverse_proxy directive.
That code similar to docs example is worked for me:
:80
reverse_proxy localhost:8000 {
#error status 500 503
handle_response #error {
respond "Something bad happened. If the error occurs again, please contact me at example#mail.com"
# i guess we can use other directives like redirect
}
}
I've got stuck with this problem for 3 days.
My Server is Centos, and use wordpress (WP) in Httpd service.
Its IP is '103.232.120.178'
I want to use nginx as reverse proxy for WP.
Httpd is in port 2101
Nginx is in port 80
WP is in sub directory: 'bongda69' (url: '103.232.120.178:2101/bongda69')
I want if visit mywebsite, it redirect to wordpress.
Ex: visit '103.232.120.178', it will display as WP site: '103.232.120.178:2101/bongda69'
My nginx.conf is:
user apache apache;
worker_processes 4;
error_log /var/log/nginx/error.log;
events {
worker_connections 1024;
}
http {
upstream backend {
server localhost:2101; # IP goes here.
}
server {
listen 103.232.120.178:80; # IP goes here.
location / {
proxy_pass http://backend/bongda69/;
}
} # End server
} # End http
and in General Settings in WP, I configure:
WordPress Adress(URL): http://103.232.120.178/bongda69
Site Adress(URL): http://103.232.120.178/bongda69
But, when visit 'http://103.232.120.178', error display:
Not Found
The requested URL /index.php was not found on this server.
Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.
If I configure nginx like this:
location / {
proxy_pass http://backend/;
}
Everything is Okie. But I must visit site "http://103.232.120.178/bongda69", and I don't want it.
What is my mistake?
Anyone can help me?
Thanks a lott!!!
This should work
worker_processes 4;
error_log /var/log/nginx/error.log;
events {
worker_connections 1024;
}
http {
upstream backend {
server 103.232.120.178:2101; # IP goes here.
}
server {
listen 0.0.0.0:80; # IP goes here.
location / {
proxy_pass http://backend/bongda69;
}
} # End server
} # End http
added
I suggest adding
/var/log/nginx/access.log;
in order to see whats happens with your request
How to pass parameters in nginx url. When I hit http://127.0.0.1:1000/samp/test1/result?num1=10&num2=30, it should redirect me to http://127.0.0.1:80/samp/test1/result?num1=10&num2=30. Is this possible? Below is my nginx config file.
upstream apache {
server 127.0.0.1:1000;
}
server {
listen 80;
server_name 127.0.0.1;
location / {
#root html;
#index index.html index.htm;
#return 503;
proxy_pass http://apache;
}
}
I think what you want to do is possibe, but you'd have to make that configuration change on the apache end of things.
If 'apache' handles a request coming into port 1000 directly, it will see a URI like this:
http://127.0.0.1:1000/samp/test1/result?num1=10&num2=30
However, if it is sent through nginx, it will look more like this:
http://apache/samp/test1/result?num1=10&num2=30
So, you could check the incoming URL for :1000 and then rewrite the request on the apache side to go to port 80 instead ( which is the default, so you don't need :80 - you can just leave the port unspecified entirely.
If the backend really is apache, you can use a rewrite rule there to handle the rewriting.
However, if you're not already on port 80, you're not connecting to nginx - so nginx can't rewrite this for you.
Hope it makes sense!
Here's how I tested:
Apache side I used a quick sinatra (ruby) app to print out the full URI of the request it sees:
require 'sinatra'
set :bind, "0.0.0.0"
set :port, 1025
get "/*" do
"<p>Hello from \"apache\"! You've just requested:
<code>#{request.url}</code></p>
"
end
Then nginx is configured thusly:
upstream apache {
server 192.168.70.1:1025;
}
server {
server_name localhost;
location / {
proxy_pass http://apache;
}
}
Note I used port 1025, because port 1000 is a privileged port.
I used curl to generate the requests to test:
$ curl 'http://192.168.70.1:1025/samp/test1/result?num1=10&num2=30'
<p>Hello from "apache"! You've just requested:
<code>http://192.168.70.1:1025/samp/test1/result?num1=10&num2=30</code></p>
$curl 'http://127.0.0.1:80/samp/test1/result?num1=10&num2=30'
<p>Hello from "apache"! You've just requested:
<code>http://apache/samp/test1/result?num1=10&num2=30</code></p>
If I wanted to do the redirect you're describing, I could match with a regular expression of IPV4 address and port and redirect as such:
get "/*" do
if request.url =~ %r|^http://([0-9]{1,3}\.){3}[0-9]{1,3}:1025/|
redirect "http://localhost:80/#{request.fullpath}"
else
"<p>Hello from \"apache\"! Tou've just requested:
<code>#{request.url}</code></p>
"
end
end
Now I tell curl to follow redirects (-L) and we see it redirect me over to the "correct" route.
$ curl -L 'http://192.168.70.1:1025/samp/test1/result?num1=10&num2=30'
<p>Hello from "apache"! Tou've just requested:
<code>http://apache/samp/test1/result?num1=10&num2=30</code></p>
I know it's not the language you're using, but I hope it iwll help you get started.
As known Amazon does not support https connection with custom URL to static site located on S3
To solve the problem I configured :
Route53 with custom domain
Load Balancer (ELB) to redirect port 443 to 80 + to install SSL license on it
Amazon Linux server + ngnix on it for http redirection to domain name that Amazon provided for S3
on Amazon Linux I configured in /etc/nginx/conf.d/virtual.conf :
server {
listen 80;
server_name my_root_domain.com;
rewrite ^ $scheme://my_root_domain.com.us-east-1.amazonaws.com/$request_uri? permanent;
}
URL I get on web browser is "my_root_domain.com.us-east-1.amazonaws.com" instead of my_root_domain.com
Second question: I also want to redirect www.my_root_domain.com to S3
Thanks for any help , I just started with nginx
You want to use nginx as a forward proxy, probably something like:
server {
listen 80;
server_name my_root_domain.com;
location / {
proxy_pass http://my_root_domain.com.us-east-1.amazonaws.com;
}
}