Nginx vs Apache or using Apache with nginx [closed] - apache

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 9 years ago.
Improve this question
I have been running a website which servers javascript widgets for about 2 years. Now my question is whether I should use nginx purely or I should continue using apache with nginx.
I have about 200 sign ups a day and that means that sometimes the request rate for widget goes up by 2000 a day. So, now the problem is switching to nginx means that i would not be able to use the rewrite rules that i am using in apache.
Now that is one problem I know of, but are there any other issues that I can expect to see in an nginx environment that I dont in Apache?
Would you suggest me to switch purely to nginx or stay with apache and nginx as reverse proxy?

You could still use the rewrite rules from Apache, with slight modifications (I took this from Nginx Primer):
Apache:
RewriteCond %{HTTP_HOST} ^example.org$ [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]
Nginx:
if ($host != 'example.org' ) {
rewrite ^/(.*)$ http://www.example.org/$1 permanent;
}
Another issue is .htaccess files, but this would only be an issue if your sharing the server with others.
I would also research any Apache modules that your relying on and ensure that the Nginx equivalents include the same functionality. Definitely test your webapp with Nginx in a test environment first to identify any issues.
In the end, if your goal is better performance then the migration from Apache to Nginx should be worth it.

Related

Convert NGINX rewrite rules to Apache htaccess [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 2 years ago.
Improve this question
I have a client who is moving away from an NGINX webserver to Apache. Everything is simple nothing complicated however since I'm an NGINX kinda guy I forgot how to convert the NGINX rewrite rules onto apache ones.
For example, these are the NGINX rewrites
rewrite ^/Tower-Topics-Calendar/?$ https://$host/events/ permanent;
How would I convert something like that onto .htaccess to use with Apache?
rewrite ^/Tower-Topics-Calendar/?$ https://$host/events/ permanent;
This looks like an external 301 redirect from /Tower-Topics-Calendar (with and without a trailing slash) to https://<host>/events/ - where <host> is the same hostname from the request and you specifically state the HTTPS protocol in the target.
In .htaccess you can achieve this using mod_rewrite. For example:
RewriteEngine On
RewriteRule ^Tower-Topics-Calendar/?$ https://%{HTTP_HOST}/events/ [R=301,L]
Note the absence of the slash prefix in the RewriteRule pattern.
However, if you don't specifically need to include the HTTPS scheme (ie. this is already canonicalised) then you can use a single mod_alias RedirectMatch directive instead. For example:
RedirectMatch 301 ^Tower-Topics-Calendar/?$ /events/
OR, to include the HTTPS protocol, you need to hardcode the hostname:
RedirectMatch 301 ^Tower-Topics-Calendar/?$ https://example.com/events/

Redirect domain to another domain and change url [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
I have a website on
mydomain.eu
and i want to redirect
mydomain.com
and
mydomain.org
to mydomain.eu. I want the url in the address bar to change to mydomain.eu.
Are there multiple ways to do this?
For Example:
apache virtualhost
htaccess
dns records/domain forwarding from registrar
programmatically
other
Can you give an example of each?
The options you give are correct:
apache virtualhost
You can create a redirect here, when you do that you have to point the DNS records to the server where apache is running:
an example can be found here:
https://www.digitalocean.com/community/tutorials/how-to-create-temporary-and-permanent-redirects-with-apache-and-nginx
htaccess
Similar to the virtualhost solution except that he redirect is made in another file example: Redirect all request from old domain to new domain
dns records/domain forwarding from registrar
With a DNS record only you can't do a redirect it should always be used with a forwarding service or one of the other options given
programmatically
You can create a redirect in the code, you should point the DNS records to the server running the application and make your webserver listen to the domainnames.
example in PHP: How to redirect to another page using PHP
Cheers!

url rewrite `/abc/products-` to `/def/products-` [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
I have many url links in /abc/ sub-directory, like
http://www.domain.com/abc/products-12345
http://www.domain.com/abc/products-23456
http://www.domain.com/abc/products-34567
http://www.domain.com/abc/new-items
Now I want to url rewrite /abc/products- to /def/products-
http://www.domain.com/def/products-12345
http://www.domain.com/def/products-23456
http://www.domain.com/def/products-34567
http://www.domain.com/abc/new-items
My code in .htaccess, but nothing changed. How to rewrite in this case? Thanks.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^abc/products-(.*)$ /def/products-$1 [L,R=301]
</IfModule>
As you can test on this simulator the rules should work.
The most probable problem you are facing should be:
The global configuration does not allow for .htaccess overwrite
.htaccess is not readable for apache user
You have no mod_rewrite active on this apache server, thus no trigger to <IfModule> directive.
Best troubleshooting option would be trying a redirection of all page to a static page. If this does not work, look for a configuration problem.

How to forward a subdomain to a new port on the same IP address using Apache? [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
I have a NAS/Server running at home 24/7 and run many different services on it. I have got a domain name pointing to it now, and was wondering if it would be possible to create sub-domains that point to different ports for different services. For example:
http://subsonic.mydomain.com --> XXX.XXX.XXX.XXX:4040
http://minecraft.mydomain.com --> XXX.XXX.XXX.XXX:25565
http://files.mydomain.com --> XXX.XXX.XXX.XXX:4082
I have a single D-LINK router that currently port forwards all these ports to my NAS/Server whose IP is 192.168.0.104.
EDIT: The server is running Ubuntu 12.04.
What service or proxy do I need to run that can recognize the sub domain and route the traffic accordingly? Or could I use apache virtual hosts to handle this, because these subdomains will come in on port 80, which apache is listening to? Or does virtual hosts not work like this?
Any information, ideas, or tips would be helpful/useful.
There are two ways to do this. You could use the VirtualHost section of your httpd.conf or you could do it in your .htaccess. (assuming that the subdomains resolve to the same IP as your webserver)
In httpd.conf:
<VirtualHost *:80>
ServerName subsonic.mydomain.com
redirect / http://mydomain.com:4040/
</VirtualHost>
In .htaccess:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^subsonic\.mydomain\.com$ [NC]
RewriteRule ^(.*)$ http://mydomain.com:4040/$1 [R=301]
Documentation:
- Guide to creating name-based virtual hosts
- Core, including VirtualHost and NameVirtualHost
- Redirect
- mod_rewrite guide

Problem with yourls.org redirects on windows 2003 with ISAPI rewrite [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
I've setup a yourls.org (URL shortening service) on a windows 2003 VPS server I have, using ISAPI rewrite. I already have ISAPI rewrite installed and working with Wordpress, so I know that is working. I have used the rules suggested from the page:
http://code.google.com/p/yourls/wiki/htaccess
In my ISAPI rewrite, but the redirects are not working. The page is looping, trying to redirect to itself.
I'm not familiar with Rewrite rules so any help would be appreciated. The rules I've applied are:
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (/|\.php|/[^.]*)$ [NC]
RewriteRule ^(.*)$ /yourls-loader.php [L]
I added the third conditional line based on something I found in the wiki of the application.
If anyone could shed any light on why this isn't working, I'd appreciate it.
T
Ok, this took me all day, but I got it working. For anyone interested, there was absolutely nothing wrong with the ISAPI rewrite. The problem was in the code. In a file called yourls-loader.php, there's a line that checks the url, deconstructs it and reconstructs it. The problem is that it always forces the new url into https. If you've no security cert on your server it won't work!!!
//$scheme = ( isset($_SERVER["HTTPS"]) ? 'https' : 'http' );
//$request = str_replace( YOURLS_SITE.'/', '', $scheme . 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] );
$request = str_replace( YOURLS_SITE.'/', '', 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] );
The first 2 lines are commented out, this is what was here. As I trust and know how my server is setup (cause I did it myself) I don't feel any need for this check system.
One other thing to be aware of on a Windows system is that you will have to add the suggested Server_URI parse at the start of this file too.
if (isset($_SERVER['HTTP_X_REWRITE_URL'])){
$_SERVER['REQUEST_URI'] = $_SERVER['HTTP_X_REWRITE_URL'];
}
I hope this helps someone... It's taken me all day to resolve with no online support.