Hello I am try set up a CentOS based web server currently and am having trouble getting the domains to work.
I set up the httpd.conf as follows:
NameVirtualHost *:80
<VirtualHost *:80>
ServerAdmin alexgatti#msn.com
DocumentRoot /etc/httpd/www/alexandergatti.com
ServerName alexandergatti.com
</VirtualHost>
When I try to access the website the web browser says the server can't be found. I contacted my host and they said the DNS was set up corrently. Anyone have any ideas?
Did you point your domain name "alexandergatti.com" to your public ip address and do port forwarding. If you didn't point it you must point it by going to the DNS Manager zone in your domains registrant EX: Go Daddy or 1and1 and point the sites ip address to your public ip.
Next if you didn't already do this. Port Forwarding is also most important. OK so now your visitors are at your ip but your router doesn't know where to send them. So lots of routers either have them in applications and gamig or access or Virtual Server. You open it and where it says port start or public do the public port. I prefer 80 because your visitors will not have to write domain.com:8080. they just type domain.com. Ending port or private port is the ip address you set for apache. Im assuming you chose 80. So there you type 80. At the ip address or points to you type your computers private local ip which in my case is 192.168.1.205..... Click add or update or save and try your site name again. If you try it from behind your router it might not work so try it on a phone that has web in your plan or at a neighbors internet. It should work.
Also at NameVirtualHost *:80 and VirtualHost *:80 you should put your public ip instead of the star or astreics..
So it should be looking like
NameVirtualHost my.ip.add.ress:80
<VirtualHost my.ip.add.ress:80>
ServerAdmin alexgatti#msn.com
DocumentRoot /etc/httpd/www/alexandergatti.com
ServerName alexandergatti.com
</VirtualHost>
Related
I am trying to quickly set up a database for some friends to connect to (security, efficiency, and durability are not huge concerns), but I cannot determine what is causing my connection attempts to time out. Pretty much this unanswered question.
PostgreSQL and PGAdmin are created via docker-compose on (let's say) 192.168.1.100.
Everything starts fine. I confirmed that listen_addresses = '*' in the pg conf. Firewall is allowing 5432 and 5050 (pgadmin) to my local network, where my nginx server will pick it up
5050 ALLOW 192.168.1.0/24 # pgadmin
5432 ALLOW 192.168.1.0/24 # postgres
The ngnix server is redirecting a subdomain to the original server's IP and port, like so:
server {
listen 80;
server_name pg.mydomain.net;
location / {
return 301 https://$host$request_uri;
}
}
server {
listen 443 ssl http2;
server_name pg.mydomain.net;
proxy_read_timeout 600s;
location / {
proxy_pass http://192.168.1.100:5432;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
ssl_certificate /etc/letsencrypt/live/mydomain.net/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/mydomain.net/privkey.pem;
}
(this block is boilerplate that I use for all my quick projects, works 90% of the time)
Then on cloudflare I add a CNAME entry for pg.mydomain.net (also one for pgadmin.mydomain.net, which works flawlessly).
But the connection string postgresql://myuser:mypw#pg.mydomain.net:5433/mydb isn't working like it does when I access it by its local ip address directly. I'm thinking the problem lies with nginx. I'm hoping for a solution that allows my users to construct a similarly simple connection string in a Jupyter Notebook.
As was hinted at in the comments but not stated explicitly was that requests to a postgres server are not HTTP/HTTPS, thus it is probably not able to go through nginx.
The reason I (and anyone) would want it to pass through a reverse proxy is to limit the surface area of my network which is exposed to the internet to a single server. It had worked for all kinds of web apps provided by docker containers (including PGAdmin), but this assumption does not hold for data headed to a database.
I say probably not able to go through nginx because it seems like this is what the nginx stream module is for. But since that required a re-compiling and re-installation of nginx just to test a stream{} block, I did not invest the effort.
What ultimately worked is
punching a hole in my router for the postgres port, and forwarding that traffic directly to the postgres server (bypassing nginx)
setting the DNS CNAME record for the subdomain to be unproxied, whereby it doesn't benefit from Cloudflare hiding my true IP address but at least it does forward traffic correctly.
In the end, my users can connect via any database tool using hostname: pg.mydomain.net, port: 5432, username + password
I am looking to perform something quite simple.
Using haproxy I would like to forward any requests from the URL http://webmail.rutest.org or https://webmail.rutest.org to https://outlook.com/rutest.org
BASICALLY:
We currently own the domain rutest.org. What I intend to do is create a DNS "A" record for "webmail" IP address 24.103.122.18. This will then go to a FortiGate Router which has 2 port forwarding rules for 80 and 443 to an internal IP address 10.1.1.18. 10.1.1.18 will be the haproxy server. Once that request gets there, I want haproxy to say ok, you want http://webmail.rockefeller.edu or https://webmail.rockefeller.edu then send the user to https://outlook.com/rutest.org
The users browser should then reflect this URL redirection.
Can this be done? If so, what are the entries needed in the haproxy.cfg?
You can try the following, untested.
listen webmail
bind :80 v4v6
# here should be your certificates
bind :::443 v4v6 alpn h2,http/1.1 ssl crt /etc/ssl/haproxy/
http-request redirect location https://outlook.com/rutest.org if hdr(host) -i webmail.rockefeller.edu
The documentation: http-request redirect
I'm trying to create a subdomain in my virtual server (it's a centOS). I have edited the httpd.conf file like this:
NameVirtualHost *:80
<VirtualHost *:80>
DocumentRoot /var/www/html/zend/
<Directory "/var/www/html/zend">
Options Indexes FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
ServerName zend.mydomain.es
</VirtualHost>
When I try www.mydomain.es it's work fine, but when I try zend.mydomain.es I get Server Not Found error.
Are there any other files i must configure for this to work?
You should also setup dns for the your subdomain and make sure subdomain is pointing to the correct ip
Also check ping if it is replying:
ping zend.mydomain.es
If the IP is correct check both Apache logs (error.log and access.log).
I would recommend verifying your DNS settings for the subdomain.
E.g. If you are hosting with GoDaddy, I would recommend making sure
you have an entry for your subdomain there and that the IP points to
the same box.
Next, if you haven't yet, after you make your changes to httpd.conf
you need to restart the httpd service for the changes to take
affect. So try service httpd restart
Hopefully one of those helps solve your issue.
i have nginx on port 8080 sitting behind varnish running on port 80. there is only one website on my server. the problem is you can access it by server's IP address too, instead of just url. google indexed this ip and i am afraid of problems with duplicate content.
how do i redirect requests going to IP address to my URL? i tried this code, but it ended up with loop redirects error.
server {
listen 180.10.1.1:80;
server_name 180.10.1.1;
rewrite .* http://www.mysite.com$request_uri permanent;
}
thanks
edit:
rest of vcl
server {
listen 8080;
server_name site.com;
access_log /var/log/nginx/localhost.access.log;
error_page 502 /502.html;
## Default location
location / {
root /home/site.com/public_html;
index index.php;
...
There's a couple of ways to solve this. If Nginx is also serving site.com when you visit the server IP Address then you should adjust the Nginx config so any requests which are directed at the IP address redirect to site.com. Then restart both Nginx and Varnish.
ok the problem was "180.10.1.1:" in the listen directive. i kept there only "listen 80" and now it works fine :)
I have a website I am building on localhost:
http://localhost/my-website
I need to test it on my iPhone, but I'm not sure how to go about it. Do I just change my httpd-vhosts.conf file, and, if so, what are the settings?
Assuming that your development machine is called my-macbook-pro, you should just be able to navigate to http://my-macbook-pro.local/mywebsite on your iPhone.
To expand slightly on Richard J. Ross III's answer, "localhost" is a name used to refer only to the local computer. In order for your iPhone to be able to access content on that machine it must:
Have an IP address on the same network as the server machine.
This can be achieved by connecting the iPhone to a wireless access point that is on the same network as the PC, or by creating an ad-hoc wireless network between the two devices.
Respond to HTTP requests from network clients.
Assuming the server and the iPhone are on the same network, it should be possible for traffic to flow between them. However in order for your web content to be visible to the iPhone, the web server must also be configured to respond to requests made to the server machine's IP address.
This is not normally a problem as web servers are commonly configured to respond to HTTP requests sent to any of the machines IP addresses. It is possible that a server could be configured to only respond to local requests, however this is not a typical default setting
How you check or modify this setting is dependent upon the HTTP server software you are using. As this information is not specified I will include instructions for Apache2 as this is a very common choice of HTTP server.
Apache's Listen Directive
Apache's main configuration file is httpd.conf and it is located in the conf subdirectory of your Apache directory. The location of your Apache root directory will vary depending upon what operating system you are using and whether or not a custom location was chosen at installation.
The httpd.conf file contains a directive named Listen which controls the interface (IP address and port) on which Apache listens for incomming HTTP requests.
The default form of this directive is commonly
Listen 80
This specifies that the machine will respond on any of it's IP addresses to requests made on port 80, which is the default port for HTTP traffic.
You can modify the Listen directive to use any address associated with the machine including the loopback address (127.0.0.1) which the name localhost resolves to.
If Apache is set up to only listen on the loopback address then your server machine will only respond to requests made on the local machine. In this configuration, your Listen directive will look something like:
Listen 127.0.0.1:80
If this is the case, you will need to change to either listening on all addresses, as in the example above, or listening only on the address used by the iPhone to communicate with the server machine.
100% working solutions
(for linux + apache + vhosts)
If you are using vhost (several sites on the same server apache) the next several tips can help you view your local websites on mobile:
1) VHOST edit -You should go to /etc/apache2/sites-available/ on your server. There can be several files .conf, each file contain a virtual host configuration for apache. Default file will look like 000-default.conf. Open it (or another one) with admin permissions sudo. In that file you should see something like this:
<VirtualHost *:80>
ServerName auction.dev
ServerAdmin test#test.com
DocumentRoot /var/www/public_html/html
ErrorLog /var/www/logs/error.log
CustomLog /var/www/logs/access.log combined
</VirtualHost>
2) XIP.IO - this special service (its totally free) can help you. You should add to .conf file next line - ServerAlias auction.dev.*.xip.io, after this operation your file will look like this:
<VirtualHost *:80>
ServerName auction.dev
ServerAlias auction.dev.*.xip.io
ServerAdmin test#test.com
DocumentRoot /var/www/public_html/html
ErrorLog /var/www/logs/error.log
CustomLog /var/www/logs/access.log combined
</VirtualHost>
After editing you should save this file and restart apache with command sudo apachectl restart.
3) View from mobile - You need to know ip of your server, in my situation ip = 192.168.1.247. Now in your mobile browser just type auction.dev.192.168.1.247.xip.io and you should see your local website.
I'm working with xampp. localhost works on port 8080.
I just find my ip with ipconfig and surf to http://10.0.0.1:8080.
That easy!
If you just want a better feel of the native behavior instead of just browser dev tools you can use the iOS simulator and type localhost:xxxx in safari app.
For OSX, go to System Preferences / Sharing. There, you can find and change the name of your computer. In the same section, you also have to enable "Internet Sharing" service with "iPhone USB" port.
Then you can view your website at http://{ computer_name }.local/my-website.
When you connect your ipod with the cable to your macbook the device appears in safari on your mac in the menu under developers. When you click this option you can see exact the same as you can on your ipod.
Following these steps worked for me:
https://mtm.dev/iphone-localhost-mac
It is based on Internet Sharing via USB and setting & using the device_name which is then used as mentioned as <device_name>.local:<port>