Apache & Nginx in Same Directory - apache

I want to use Apache and Nginx in the same directory:
nginx root /home/admin/tv;
Apache DocumentRoot domain root /home/admin/tv;
I set the same directory but when I go to the Nginx addreess
ip:777 i got 403 Forbidden nginx/0.8.54
I finally change the permission and it works.

There's no reason you can't run one of each. They just have to bind to different sockets. The 403 error is because you configured permissions incorrectly.

I was playing with this earlier, I have apache and nginx and testing both on my server. you should be able to use the same directory with existing sites as long as you make the changes in your virutal host of both to reflect you chosen directory. I don't think you can run both at the same time though.

Related

Domain Name cannot be changed in Apache on CentOS 7

I have set up a server with a wiki and Wordpress and Nextcloud on a new Domain, let's say it's testing.com. When I was finished, I wanted to change the Domain from testing.com to realdomain.com.
The server is running CentOS 7 with httpd (apache), so I changed the ServerName in /etc/httpd/conf/ to "realdomain.com". Then I changed the VirtualHosts in all the files in /etc/httpd/conf.d.
I added the new Domain to the trusted Domains of the Wordpress, Nextcloud and wiki. I restarted the httpd service and the server itself.
Yet, when I open realdomain.com in browser, it shows me my websites, but it puts testing.com in the address field.
I tried using mod_rewrite to change the URL, but then my webbrowser tells me that the site doesnt redirect correctly and that the redirects never stop.
I tried those rewrite rules in the .conf files and in the .htaccess (not simultaneously)- no success.
I removed all my files in conf.d and created a new DocumentRoot with a simple helloWorld.html - The Url still gets rewritten to testing.com.
Are there any other locations that could have rewrite rules? Did I miss anything?
Thank you so much in advance, this is killing me!

Apache as a proxy for multiple nginx servers

I'm starting from the bitnami jenkins stack. Everything is working perfectly with jenkins.
http://sample:8080/jenkins (works fine)
I'm trying to add additional directories to apache to proxy to nginx:
http://sample:8080/other_tool
I can get to the other_tool homepage, but references to that other tool break down because they are looking for http://sample:8080/relative_url rather than http://sample:8080/other_tool/relative_url
I can pull config settings from the necessary files as needed, but it is on an air-gapped network so wholesale posting would be a challenge
The apache conf looks like:
<Directory /other_tool>
ProxyPass http://localhost:9999
ProxyPassReverse http://localhost:9999
</Directory>
The nginx configuration is a standard "/" with root directory. I'm not as familiar with nginx so I can't recall the exact information off the top of my head. If needed I will provide it.
I could try to switch the jenkins hosting over to nginx, but I'm not sure that simplifies anything.
I can't open more ports on the machine. I can't use a subdomain as that would require additional DNS entries that I do not control.
Ideas or suggestions?

DigitalOcean hosting with GoDaddy domain denying access to root directory

I own a domain on GoDaddy and am attempting to point it to my DigitalOcean-hosted website. Here are the steps I have taken so far:
I cloned the git repo containing all of my website files from local to my DigitalOcean server.
I added an # record on godaddy for my domain and pointed it to my DigitalOcean IP address.
IMPORTANT!! I modified /etc/apache2/sites-enabled/000-default.conf with my new VirtualHost pointing mydomain.com to index.html, NOT THE ROOT DIRECTORY.
I then proceeded to do 'service apache2 restart' while sshed to DigitalOcean on terminal.
I assumed this would work and then tested it out and went to mydomain.com. Not so much. This is the error I got:
Forbidden
You don't have permission to access / on this server.
Apache/2.4.7 (Ubuntu) Server at mydomain.com Port 80
This was obviously pretty surprising given that it was not redirecting to index.html, so I manually appended /index.html to mydomain.com only to find that it gave me an identical error only I could not access /index.html instead of /.
I have done this kind of things many times before, however I used subdomain records for godaddy on an existing domain instead of using a brand new domain with no subdomains. Where did I go wrong?
Thanks!
Brandon
UPDATE: I tried on a test subdomain with test.mydomain.com and got this new error:
Not Found
The requested URL / was not found on this server.
Apache/2.4.7 (Ubuntu) Server at test.mydomain.com Port 80
You noted you modified the virtual host to point to index.html but not the root directory. Apache would still use the root directory (DocumentRoot) to locate the index.html file. If it is looking in the wrong location it could explain the 403 error (looking in a place that the web server user [www-data] cannot read as an example).
Beyond that, a 403 like that could be permission related. You would want to ensure the DocumentRoot and index.html file have the ownership of www-data:www-data and they are all readable by the web server itself (755 for folders and 644 for files is the norm).

How do I find out where my root URL is being served from in Apache?

I've recently got a VPS server and it came installed with CentOS, WHM and cPanel. I'm trying to find where the physical folder location the root URL of the server IP is being served. When I go to the root IP in a browser, I get a redirect to "/cgi-sys/defaultwebpage.cgi" with "SORRY!" and some error resolve details.
The server has a web-site running under "/cPanel" and also WHM runs on ":2083".
I'm trying take control of the content served directly at the /, and replace that defaultwebpage.cgi with an index.html.
I've tried httpd -V to check where the httpd.conf, is and then spotted a <VirtualHost *> in that config file, which points to a DocumentRoot of /use/local/apache/htdocs . But if I place index.html in this folder and try to hit it via /index.html, I still get routed to that defaultwebpage.cgi. Can anyone help me understand why its rerouting and not picking up that index.html?
Thanks.
You may want to try /var/www/html, at least that's in Ubuntu
If it's not it, then try going to /etc/apache2/apache2.conf and find the DocumentRoot option.
Hope this helps!

Redirecting to Amazon EC2 AMI Instance

I'm trying to redirect a router to a certain PHP page stored on what I think is CentOS on my AMI (Amazon Machine Image). I've done a bit of research and have found that other people were having the same problem: I've looked here, and here and what I got was that I need an elastic IP for the instance that has the page I want to redirect to, but I already have that.
I've tried ec2-xx-xxx-xxx-xxx.us-west-2.compute.amazonaws.com/root/path/to/page, as well as (just the IP) xx.xxx.xxx.xxx/root/path/to/page and nothing seems to work. I'm so confused. I don't need a particular domain to redirect to my AMI so I don't need to map my domain's DNS to the elastic IP.
Okay, so I figured out the problem with the redirection. Essentially, I have Apache running on my CentOS AMI. As Apache, I think, handles most if not all HTTP requests, the request for the particular page on my AMI was being handled by Apache. What I did was that I looked in the configuration files of Apache on the AMI which are under etc/httpd/conf on CentOS at least (I don't know about other distributions), and opened httpd.conf (full path: /etc/httpd/conf/httpd.conf).
I looked for the particular line that had the DocumentRoot (this line sets the directory from which Apache will serve files) directive and saw that it had "DocumentRoot "/var/www/html".
What I was doing wrong was that my redirection URL was set to ec2-xx-xxx-xxx-xxx.us-west-2.compute.amazonaws.com/root/path/to/page instead of just ec2-xx-xxx-xxx-xxx.us-west-2.compute.amazonaws.com/page because I didn't know Apache was automatically appending /var/www/html before /page.
So since my redirection URL was set to ec2-xx-xxx-xxx-xxx.us-west-2.compute.amazonaws.com/var/www/html/page, when Apache was getting the request it would append another /var/www/html and look in ec2-xx-xxx-xxx-xxx.us-west-2.compute.amazonaws.com/var/www/html/var/www/html/page.