Lighttpd : proxy on another local website - unix

I'm currently stuck on a proxy problem : I use lighttpd to serve html pages on port 443, and now I want to access another local website (only accessible with localhost) and with https, while he can't handle it.
My solution's to use lighttpd as proxy to redirect all requests of the interface 192.168.x.x: in the local interface (127.0.0.1:).
As example, if my local server's on port 8080, all the 192.168.x.x:8080 are redirect on 127.0.0.1:8080, but the url in my browser still 192.168.x.x:8080. With this configuration, i can let lighttpd setup https.
But now I'm stuck on the redirection, i use mod_proxy but nothing work and the page can't be found :
$SERVER["socket"] == "192.168.x.x:8080" {
ssl.engine = "enable"
ssl.pemfile = "/etc/ssl/server.pem"
proxy.server = ( "" => (
"api:8080" => # name
( "host" => "127.0.0.1", # Set the IP address of servername
"port" => 8080
)
)
)
}
what did a do wrong ?
Thanks in advance !
PS : I use the version 1.4.53 of lighttpd
EDIT
To be more precise, I just want a basic proxy usage from ligttpd :
I add ssl engine and ssl pemfile for my 8080 port listener

Related

How to add and resolve URL as we do with host name after adding it in /etc/hosts file

I have a web app running on machine with ip : 172.10.10.10.
The basic API call exposed by this app is : GET - http://172.10.10.10
and it will return a response as OK.
On another machine I added an entry in /etc/hosts file as below.
172.10.10.10 webserver1.com
With this the ping command is resolved successfully. e.g. : ping webserver1.com
Now I want to resolve the curl command as well.
e.g. : curl http://webserver1.com
Result : curl: (6) Could not resolve host: webserver1.com
How to achieve this for curl command with http url?
You can setup a DNS server and point your IP in /etc/resolv.conf
There are many options out there in marker ( paid / free ) for a Local DSN Server dockerized and non-dockerized too.

How to redirect HTTPS traffic to local HTTP server using mitmproxy?

I am trying to setup mitmproxy so that I can make a request from my browser to https://{my-domain} and have it return a response from my local server running at http://localhost:3000 instead, but I cannot get the https request to reach my local server. I see the debugging statements from mitmproxy. Also, I can get it working for http traffic, but not for https.
I read the mitmproxy addon docs and api docs
I've installed the cert and I can monitor https through the proxy.
I'm using Mitmproxy: 4.0.4 and Python: 3.7.4
This is my addon (local-redirect.py) and how I run mitmproxy:
from mitmproxy import ctx
import mitmproxy.http
class LocalRedirect:
def __init__(self):
print('Loaded redirect addon')
def request(self, flow: mitmproxy.http.HTTPFlow):
if 'my-actual-domain-here' in flow.request.pretty_host:
ctx.log.info("pretty host is: %s" % flow.request.pretty_host)
flow.request.host = "localhost"
flow.request.port = 3000
flow.request.scheme = 'http'
addons = [
LocalRedirect()
]
$ mitmdump -s local-redirect.py | grep pretty
When I visit the url form my server, I see the logging statement, but my browser hangs on the request and there is no request made to my local server.
The above addon was fine, however my local server did not support HTTP2.
Using the --no-http2 option was a quick fix:
mitmproxy -s local-redirect.py --no-http2 --view-filter localhost
or
mitmdump -s local-redirect.py --no-http2 localhost

Synology Port forwardding according to subdomain

In my router setting, I have set as following:
port 5000 - my synology disk station entry
port 1337 - my router panel
And I have set some subdomain to my external IP using DDNS:
wifi.example.com
disk.example.com
www.example.com
What I want to do is:
wifi.example.com redirect to port 1337 and go into router panel
disk.example.com redirect to port 5000 and go into synology panel
www.example.com go to synology web station server
I have tried set port 80 to my disk station in router setting, and want to do redirection in disk station via nginx or reverse proxy which provided by synology. However, I cannot find the nginx.conf in the synology. I tried set the reverse proxy but fail.
Can anyone provide me any clues for this? Appreciate for any help.
I think it must be possible...
unfortunateley it is not possible to specify a port with a DNS entry
but I think the setup you wish must be possible with nginx
the nginx configuration on the Synology is somewhat different
so when you setup wifi.example.com to your home ip-address
then you have to configure your router to port-foward port 80 to port 80 on your synology
on your synology you need to configure the www-station, so the nginx is really the backend. In my case it was first set to Apache
in the www-station you have to create a virtual host entry
after that you have to open a ssh session to your synology
and do a: cd /var/packages/WebStation/etc
the Nginx configuration is in the VirtualHost.json file
in this case you should see something like below:
"eeb4adef-1fc5-4fd5-bacc-1fbd1e747d1c" : {
"backend" : 0,
"fqdn" : "wifi.example.com",
"https" : {
"compatibility" : 1,
"compression" : false,
"hsts" : false,
"http2" : false,
"redirect" : false
},
"index" : [ "index.html", "index.htm", "index.cgi", "index.php", "index.php5" ],
"php" : 4,
"port" : {
"http" : [ 80 ],
"https" : [ 443 ]
},
"root" : "/volume1/web/wiki"
},
"version" : 2
}
now you can remove the "root" line and replace it with:
"return" : "301 http://someurl:1337$request_uri"
After this modification you will have to restart the WebStation service. And when you look with the Virtual Host in WebStation via DSM it will be now presented as AbNormal, but the redirect will (in my case) be working.
I hope this input is usefull for your question.
You can also try my solution:
redirect-http-to-https
Set up a docker container for redirect.
Then you can forword 80(with subdomain) to the docker port and forword 443 to the application port
This will not change any default setting which will avoid the potential problem.

Varnish + Nginx proxy configuration on plesk

I followed the official tuto for the Varnish via Docker configuration on plesk. https://www.plesk.com/blog/product-t...cker-container
i have a VPS Ubuntu with plesk and many domains.
I followed all steps :
I created a domain test.monserveur.com
I use the Docker image million12/varnish
On the Docker container setting, the mapping redirect the 80 port to the 32780
On plesk for the hosting parameters, the option “SSL/TLS support” and “Permanent SEO-safe 301 redirect from HTTP to HTTPS” are deactivated
I deactived also the security mod for this domain
On the proxy rules of the docker container (/etc/varnish/default.vcl), i put fo the .host test.monserveur.com and .port 7080
On the function sub vcl_deliver, i put :
if (obj.hits > 0) {
set resp.http.X-Cache = "HIT";
} else {
set resp.http.X-Cache = "MISS";
}
I still have a 503 page with a MISS on the header for the page on test.monserveur.com
I can't understand where is the problem. I tried to put on the .host the serveur IP and with a link to another domain of the server. I think it's a problem with a setting but i don't know where.
Thanks in advance
A 503 error response from Varnish means that your Docker container is not configured properly. You should check whether the container and Varnish within the container are running properly. Additionally, the configuration file must have valid syntax and the correct port and IP address of the server have to be set in the configuration file.
Without knowing what you've entered, I cannot give you a better advice! If you follow the tutorial completely, it will work. I've created over 10 working instances while I wrote the text!
PS: Please use the official Plesk forum with more information (also add your configuration file) if you still cannot solve your problem - https://talk.plesk.com/
Have success!

Nginx reverse proxy.. dynamic hostname with header key and value or url path

I have got some nginx problem.I hope you will help me to solve this problem.
There are sevral servers
User PC internet networked;
Nginx proxy, hostnamed "nginxproxy", located in internal network, and it has only server which has Public IP "1.1.1.1" but jumphost, 8090 listen.
server1 hostnamed "tomcat1" located in internal network (only has private IP "70.1.1.1")
server2 hostnamed "tomcat2" located in internal network (only has private IP "70.1.1.2")
and 5, 6, ... There are more servers hostnamed apache1, apache2, redis1 etc...
Now my client wants to send http request call to server located in internal network directly. but it is not possible (because there don't have Public ips..) so the call has to passed in to nginx proxy first.
I just wander that when i call request from user pc, destination server hostname put on the request's header or url, the nginx can parse it and combine to there destination in internal network?
for example i call like this,
http://nginxproxy:1888/[destination hostname]/[path, files like index.html, some keys and values.&k1=v1. etc....]
i hope nginx pass and convert it and call there destination host like this
http://[destination hostname]:8888/[path, files like index.html, some keys and values.&k1=v1. etc....]
i tried to do this. there were some errors..
error log printed
"localhost could not be resolved (10060: Operation timed out), client: 127.0.0.1, server: localhost, request: "GET /localhost/8080/index"
server {
listen 1888;
server_name localhost;
location ~^\/([a-zA-Z0-9]+)\/([0-9]+)\/([a-zA-Z0-9]+) {
proxy_pass http://$1:$2/$3;
}
}
and one more..
in the java code,
i set like this
import org.apache.http.HttpMessage;
HttpMessage request;
request.addHeader("destinationHost", "tomcat2");
request.addHeader("destinationPort", "8888");
and call to this url
http://nginxproxy:1888/[path, files like index.html, some keys and values.&k1=v1. etc....]
can nginx convert url to
http://tomcat2:8888/[path, files like index.html, some keys and values.&k1=v1. etc....]
and pass to there??
if so, how can i set nginx.conf
thank you so much and have a nice day..

Resources