How can I do nginx rewrite?

Let’s learn how can I do nginx rewrite. The most accurate or helpful solution is served by Server Fault.

There are ten answers to this question.

Best solution

How to rewrite the domain part of Set-Cookie in a nginx reverse proxy?

I have a simple nginx reverse proxy: server { server_name external.domain.com; location / { proxy_pass http://backend.int/; } } The problem is that Set-Cookie response headers contain ;Domain=backend.int, because the backend does not know it is being reverse proxied. How can I make nginx rewrite the content of the Set-Cookie response headers, replacing ;Domain=backend.int with ;Domain=external.domain.com? Passing the Host header unchanged is not an option in this case. Apache httpd has had...

Answer:

Starting in 1.1.15, proxy_cookie_domain option was added to address this issue. http://wiki.nginx.org...

Read more

Tobia at Server Fault Mark as irrelevant Undo

Other solutions

What's the best way to add wildcard subdomains to nginx?

I've just started using nginx on my personal server, and I'd like to redirect a DNS wildcard *.socialuxe.com to various directories on my server (say ads.socialuxe.com to /ads/, etc.) Should I use some type of nginx rewrite rule?

Answer:

something like: if ( $host *~ (.*)\.socialuxe.com) { set $dir $1; rewrite (.*) $dir/$1; }

Read more

Martin Redmond at Quora Mark as irrelevant Undo

I'm having difficulty configuring my nginx server to be a Python and PHP-based app server. Could you help me with my configuration nginx.conf file?

Here's how I'd like the server configured: I'd like my nginx server to determine the URL of the incoming request and redirect it to static content. If the request is for a PHP resource, I'd like the server to redirect to my PHP FastCGI process. If the...

Answer:

I'm not sure how the server even started with that. try_files $uri $uri/ @app; First it will try $uri...

Read more

Paul Buonopane at Quora Mark as irrelevant Undo

How do I upload GB files with Nginx + PHP, if it aborts when handing over from Nginx to PHP?

Okay, what I'm trying to achieve, is to be able to upload files that are several GB of size. I've set up a VM for testing purposes, with CentOS, 2Gb RAM, 40Gb disk that runs Nginx 1.0.15 and PHP 5.5.4 (fpm-fcgi). In the nginx site file, I have: location...

Answer:

You may also want to check the max_input_time and max_execution time. It could be that the max size...

Read more

Kwan Lowe at Quora Mark as irrelevant Undo

How can I start "Nginx" after I stopped it?

I have this message nginx: [emerg] location "/" is outside location "/nginx_status"...f:67  nginx: configuration file /etc/nginx/nginx.conf test failed  nginx.service: control process exited, code=exited status=1  Failed to start...

Answer:

I think you will have better luck with Stack Overflow than here. Anyway, seems like a config error to...

Read more

Yuta Aoki at Quora Mark as irrelevant Undo

Does nginx perform well as both app load balancer and static web server, or is it better to offload static files to other servers?

For example - a farm of nginx servers taking in all requests on port 80. Path that starts with /static will be served from nginx and all other requests go to tomcat server farm. Obviously putting /static behind a CDN would be ideal but current implementation...

Answer:

Yes, nginx can do both functions very effectively. I'm assuming you're even asking this question because...

Read more

Suraj Kumar at Quora Mark as irrelevant Undo

Does it make sense to put Nginx in front of HAProxy?

We have a scaling cloud-based setup that is running 1 application server most of the time, scaling up to 2 or 3 servers during peak hours. For load balancing, we use HAProxy on a separate machine. Now on the load balancing machine we would like to serve...

Answer:

One use-case is to use nginx to terminate SSL, then forward to haproxy which then loadbalances to your...

Read more

Matt Billenstein at Quora Mark as irrelevant Undo

500 internal server error nginx & 404 not found nginx?

I’ve been having this crap problem that just seemed to popup out of no-where for two days now. I use both mozilla firefox (have to use it for a part time internet assessor work at home type job) and internet explorer which I generally use otherwise...

Answer:

it has something to do with your nginx proxy server. disable the nginx proxy server in your internet...

Read more

Richard at Yahoo! Answers Mark as irrelevant Undo

Why I'm getting "Welcome to nginx!" page instead of Facebook, Google, Yahoo! or some other well-known web page?

In brief, nginx is a popular free open source web server software. That is - a software to build Internet web infrastructure. It is typically used as a high performance, high concurrency edge web server, powering millions of domains worldwide. "...

Answer:

Because this page is on *your* server.  Google is not, as awesome as that would be. It's not really...

Read more

Paul Buonopane at Quora Mark as irrelevant Undo

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.