I cant access from host machine to virtual machine webserver domain in Debian 11 - http

I have installed an apache server on a debian 11 on a virtualbox machine.
I have set the static ip to 192.168.1.69, I have added access rules to the firewall to let traffic through on port 80.
I can see the default debian webpage if I go to the windows browser and go to 192.168.1.69, I have even configured it to install webmin on 192.168.1.69:10000, which works on firefox in the host machine, and I can access it from the windows powershell in the host machine by sshing to 192.168.1.69.
I created a server at /var/www/tests.dev with a /public directory with an index.html inside with a "You made it"
I have made
chown -R www-data /var/www/tests.dev
This is the virtual server configuration:
ServerName tests.dev
ServerAdmin webmaster#tests.dev
ServerAlias www.tests.dev
DocumentRoot /var/www/tests.dev/public
CustomLog /var/log/apache2/access-tests.dev.log "combined".
I have placed in the windows hosts of the host machine the line
192.168.1.69 tests.dev
If I ping from windows powershell to tests.dev it works, if I ssh user#tests.dev it works and I can log in.
But when I do it in firefox, in the host machine, if i go to http://tests.dev there is no way, the only thing I get is "the connection has expired", I don't know what I can try anymore, I have tried everything.
But... and this is the interesing thing... if i do a wget http://tests.dev in powershell I get
StatusCode : 200
StatusDescription : OK
Content : <html>
<h1>You made it</h1>
</html>
RawContent : HTTP/1.1 200 OK
Keep-Alive: timeout=5, max=100
Connection: Keep-Alive
Accept-Ranges: bytes
Content-Length: 36
Content-Type: text/html
Date: Fri, 27 Jan 2023 14:49:00 GMT
ETag: "24-5f33de871d523...
Forms : {}
Headers : {[Keep-Alive, timeout=5, max=100], [Connection, Keep-Alive], [Accept-Ranges, bytes],
[Content-Length, 36]...}
Images : {}
InputFields : {}
Links : {}
ParsedHtml : mshtml.HTMLDocumentClass
RawContentLength : 36
Can anyone help me why cant access on firefox on tests.dev on my host machine? Thank you.

Ok, the problem as i was figuring out when i writing the question, is firefox, doesnt allow http requests, i downloaded seamonkey and tried "http://tests.dev" now i see the page with the "you made it"

Related

Unable to configure proxy for ASP.NET application to be viewed on Apache website

I am doing a project where a running ASP.NET application (ran by dotnet core) is to be portrayed on a website via apache. I am having trouble with the proxy and get some interesting log errors I can't understand.
[Fri Jan 06 10:54:01.049808 2023] [proxy_http:error] [pid 17756:tid 3045061632] (20014)Internal error (specific information not available): [client 5.150.205.190:61781] AH01102: error reading status line from remote server localhost:7199, referer: http://www.website.me/
[Fri Jan 06 10:54:01.050039 2023] [proxy:error] [pid 17756:tid 3045061632] [client 5.150.205.190:61781] AH00898: Error reading from remote server returned by /favicon.ico, referer: http://www.website.me/
The VirtualHost is kept simple
<VirtualHost *:80>
ServerName www.website.me
ServerAlias www.website.me
ProxyPreserveHost On
ProxyRequests On
ProxyPass "/" "http://localhost:7199/"
ProxyPassReverse "/" "http://localhost:7199/"
</VirtualHost>
I've consulted with ChatGPT, referring me vaguely to possible network issues between the application and apache. But since both are running I don't see the issue with simply pointing to the localhost view. I can view it locally in browser. Why can't I point to it?

Infinite redirect in Symfony

I'm setting up a test environment for our Symfony web site. I have a basic version working on my Windows machine for development, but trying to set up an AWS replica of the production web site as test causes all the valid pages to end up in an infinite 301 redirect. I'm guessing I've missed something in the configuration.
Symfony 2.8
AWS Ubuntu server
SSL enabled, and non-Symfony files served correctly
This is the raw response header for /app/dashboard:
HTTP/1.1 301 Moved Permanently
Cache-Control: no-cache
Content-Type: text/html; charset=UTF-8
Date: Mon, 06 Nov 2017 05:43:18 GMT
Location: https://****.***/app/dashboard
Server: Apache/2.4.7 (Ubuntu)
X-Powered-By: PHP/5.5.9-1ubuntu4.22
Content-Length: 424
Connection: keep-alive
The Apache, PHP and Symfony /app/config/parameters.yml configurations are identical to the Production and Dev environments, except for server addresses. Composer has been run to download all the project dependencies.
Production and Dev both work fine. It's only Test that has the infinite redirect loops.
I'm sure there's something simple I've overlooked but I can't find it.
UPDATE 8 Nov 2017
/app_dev.php works, but /app.php has the infinite loop.
GET /app.php (https)
Location: http://****.***/
GET / (http)
Location: http://****.***/app/dashboard
GET /app/dashboard (http)
Location: https://****.***/app/dashboard
GET /app/dashboard (https)
Location: https://****.***/app/dashboard
Unfortunately, the problem went away "by itself". I had tried a few things to debug it that didn't work, so I used rsync to reset all the files back to a pristine state, at which point the problem stopped happening.
UPDATE
I managed to break it again somehow. I then remembered I'd changed the trusted_proxies in the configuration, and that got overwritten when I rsync'd it. Adding the correct settings back in fixed the problem!
framework:
...
trusted_hosts: ~
trusted_proxies: [<correct settings go in here>]
...

How do you redirect a bare "example.com" domain to "https://example.com"?

Title really says it all. I cannot get my domain to redirect from site.com to http://example.com but https://example.com works as well as https://www.example.com.
My nginx conf is as follows with sensitive paths removed. Here is a GIST link to all my nginx setup, it is currently the only enabled domain in my entire nginx configuration.
Console output on my local vs my server:
rublev#rublevs-MacBook-Pro ~
• curl -I rublev.io
^C
rublev#rublevs-MacBook-Pro ~
• ssh r
Welcome to Ubuntu 16.04.2 LTS (GNU/Linux 4.4.0-75-generic x86_64)
* Documentation: https://help.ubuntu.com
* Management: https://landscape.canonical.com
* Support: https://ubuntu.com/advantage
Get cloud support with Ubuntu Advantage Cloud Guest:
http://www.ubuntu.com/business/services/cloud
78 packages can be updated.
0 updates are security updates.
Last login: Fri May 12 16:41:35 2017 from 198.84.225.249
rublev#ubuntu-512mb-tor1-01:~$ curl -I rublev.io
HTTP/1.1 200 OK
Server: nginx/1.10.0 (Ubuntu)
Date: Fri, 12 May 2017 16:41:43 GMT
Content-Type: text/html
Content-Length: 339
Last-Modified: Thu, 20 Apr 2017 20:47:12 GMT
Connection: keep-alive
ETag: "58f91e50-153"
Accept-Ranges: bytes
I am at my wits end, I truly have no idea what to do now, I've spent weeks trying to get this working.
LetsEncrypt is using http by default, just to be safe, it's preferable to leave the ability for it to access the well-known for the acme challenge. You also don't seem to be pointing to the right path for it, unless you changed your webroot to /home/rublev/sites/rublev.io?
I would try to rewrite your default server like this instead of redirecting directly to your https equivalent. Besides, it will allow you to test more easily this strange behavior.
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name rublev.io www.rublev.io;
location / {
return 301 https://$server_name$request_uri;
}
location ~ /.well-known {
# Apparently you changed your webroot,
# just make sure that the file is created and accessible
root /home/rublev/sites/rublev.io/.well-known;
}
}
Also, it's very important to know that you need either two different certificates or one that accept your domain both with and without www form. If that was not the case, that might very well be the reason of your issue. To generate a cert with both domains, you can run the following command:
sudo ./certbot-auto certonly --standalone -d rublev.io -d www.rublev.io --dry-run
I would also comment out your jenkins server and configs, just in case it's messing with your main one. Note: from this question, you can use proxy_redirect http:// $scheme://; instead of the form you're currently doing. It shouldn't affect another server, but I prefer to be sure in these weird scenarios.
Another thing, that might be the path to another solution, would be to consider picking only one form of your domain (either with or without www), and redirecting users from the "wrong" to the "right" one. This will allow you to get more consistent urls, better for SEO and people sharing your links.
Add the server
server {
server_name example.com;
return 301 https://example.com$request_uri;
}

Getting 404 error if requesting a page through proxy, but 200 if connecting directly

I am developing an HTTP proxy in Java. I resend all the data from client to server without touching it, but for some URLs (for example this) server returns the 404 error if I am connecting through my proxy.
The requested URL uses Varnish caching, so it might be the root of problem. I cannot reconfigure it - it is not my.
If I request that URL directly with browser, the server returns 200 and the image is shown correctly.
I am stuck because I even do not know what to read and how to compose a search request.
Thanks a lot.
Fix the Host: header of the re-issued request. The request going out from the proxy either has no Host header or it is broken (or only X-Host exists). Also take note that the proxy application will execute its own DNS lookup and that might yield a different IP address than your local computer (where you issued the original request).
This works:
> curl -s -D - -o /dev/null http://212.25.95.152/w/w-200/1902047-41.jpg -H "Host: msc.wcdn.co.il"
HTTP/1.1 200 OK
Content-Type: image/jpeg
Cache-Control: max-age = 315360000
magicmarker: 1
Content-Length: 27922
Accept-Ranges: bytes
Date: Sun, 05 Jul 2015 00:52:08 GMT
X-Varnish: 2508753650 2474246958
Age: 67952
Via: 1.1 varnish
Connection: keep-alive
X-Cache: HIT

Site is redirecting from http:// to http://http// (no colon)

We are transferring servers tonight, and we started the process. The new DNS has resolved and everything, but if you type in the site name localreviewengine.com. It kicks it to http//localreviewengine.com (so really, http://http//localreviewengine.com).
What would cause that? It's a wordpress install, and Sitename and Home in the DB are set properly, there are no redirects in CPanel, and the htaccess looks fine?
EDIT: It looks like localreviewengine.com/readme.html works though..?
Watching the response headers for this site brings a bit light into the dark:
~ # curl -I "http://localreviewengine.com/"
HTTP/1.1 301 Moved Permanently
Date: Sat, 01 Dec 2012 01:57:11 GMT
Server: Apache/2.2.22 (Unix) mod_ssl/2.2.22 OpenSSL/1.0.0-fips DAV/2 mod_auth_passthrough/2.1 mod_bwlimited/1.4 FrontPage/5.0.2.2635
X-Powered-By: PHP/5.2.17
Location: http://http://localreviewengine.com
Content-Type: text/html
As you can see webserver is redirecting to http://http://localreviewengine.com
That's a typo / incorrect protocol prefix in your configuration.
check your apache config or (most likely) your document root .htaccess
Did you add any redirect / rewrites for the move process? e.g. we're moving our site, come back when the 5.000 machines are finally up and running again? (hopefully)

Resources