How to configure nginx with running apache?

Greetings !!

I am new to nginx and seeking some help from this list.

I already have apache running with vhosts and like to install nginx as a
frontend accelerator before apache.
How can I configure nginx so that it can simply run with apache vhost ?

Thanks

you should make your apache listen on 127.0.0.1:80 and nginx on your
external IP:80 (443 if you need ssl)

did you checked the manuals in wthe wiki?

Getting Started | NGINX → proxying examples

http://wiki.nginx.org/LikeApache-> all you need for a start

after this you should check proxy_cache and different location {} -
setups
for your static
files.

Posted at Nginx Forum:

Can anyone tell my what thebenefits are ( apart from .htaccess support,
which I see all too often as a curse ) why anyone would do this in
preference to just using a pure nginx solution?

Sorry this is a bit of a hijack, but as a long time ( 1.3 on ) apache
user, and nginx convert, I can’t see why you would.

Steve

Can anyone tell my what thebenefits are ( apart from .htaccess
support,
which I see all too often as a curse ) why anyone would do this in
preference to just using a pure nginx solution?

  • out-of-the-box running stuff like mod_php / suphp
  • excessive use of rewite-rules in .htacces to make urls look like
    REST-like
    (typo3)
  • well tested environments

Posted at Nginx Forum:

Hello,

thanks for your responses and wiki link.

Regarding setup nginx before apache; I already have running vhosts with
apache and a lot og .htaccess rules.
Hence I have to place nginx before apache without disturbing the setup.

Thanks

I’ve had a situation whereby a legacy django install was running on
apache, nginx was used for caching static content on this and to serve
other locations.

I have another server that started off infront of apache and one by one
over several weeks vhosts were migrated to nginx with the default site
just a proxy to apache. I think there’s one site still like this as the
site’s important and the owner’s too lazy^Wbusy to test the nginx
version that’s been setup.

Steve.

On 17/04/2014 11:34, Steve H. wrote:

I am new to nginx and seeking some help from this list.


nginx mailing list
[email protected]
nginx Info Page [1]

Links:

Hence I have to place nginx before apache without disturbing the
setup.

works seemlessly and speeds up your apache, when using proxy_cache,
assuming your
apache listens on 8080

server {
listen 80;
server_name myhost;
location / {
root /path/to/myapp/public;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Server $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://apache:8080;
}
}

from this basic snippet you can go on and test different setups
with additional nginx-virtualhosts before making changes work in your
prod-environment

server {

this is for testing new setups

listen 81;
server_name myhost;
location / {
root /path/to/myapp/public;
proxy_cache cache;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Server $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://apache:8080;
}
}

Posted at Nginx Forum:

Hello,

I have installed and configured nginx for a existing domain, but I get
“it
works” at the browser.

I have changed all port from 80 to 8080 in apache vhost and create same
vhost in /etc/nginx/vhosts.d/mydomain.conf as below

server {
listen 80; # Default listen port
server_name site.mydomain.com;
access_log /var/log/nginx/dustri.de;
gzip on; # Turn on gZip
gzip_disable msie6;
gzip_static on;
gzip_comp_level 9;
gzip_proxied any;
gzip_types text/plain text/css application/x-javascript text/xml
application/xml application/xml+rss text/javascript;

location / {
proxy_redirect off; # Do not redirect this proxy - It needs to be
pass-through
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Server-Address $server_addr;
proxy_pass_header Set-Cookie;
#proxy_pass http://127.0.0.1:6081; # Pass all traffic through to
Varnish
proxy_pass http://127.0.0.1:8080;
}
}

obviously site.mydomain.com has been replaced by the actual site to
visit.

What else should I configure here ?

Thanks