By guiffo
Hello
I am using nginx as reverse proxy server (front-end server) + apache as back-end server.
I notice I could NOT get the rewritten url output in php (like www.example.com/something/page/) with $_SERVER[“HTTP_HOST”].$_SERVER[“REQUEST_URI”] in nginx but it works in apache.
Note: The nginx rewrite works fine in the url but the problem is the output in php code.
I am getting such un-rewritten urls like www.example.com/index.php?a=something&b=page with $_SERVER[“HTTP_HOST”].$_SERVER[“REQUEST_URI”]
Can someone please help if I am doing something wrong?
This is the proxy part of my nginx
location ~ \.php$ {
proxy_pass http://127.0.0.1:8080;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
This question was answered by @EpicCDN:
If you are using apache, you don’t really need to create rules of redirection on nginx, as nginx is just a cache in this case.
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.