Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I can't find a mistake in my NGinx config. I have a website launched on http://local_ip:8079 and need to make it accesible by outer usage by the url http://example.com/judge. So, page served localy at url http://local_ip:8079/home.html to be accessible by http://example.com/judge/home.html and so on. I made a config:

server
{
    listen 80;
    server_name example.com;
    location /judge/
    {
        proxy_pass http://local_ip:8079/;
        proxy_redirect / http://example.com/judge/;
        proxy_set_header Host $proxy_host;
    }
}

Pages are loaded but scripts and images appear in webpage source with unchanged url (i.e. /style.css) and are not loaded by browser. Which directive I should add?

share|improve this question

1 Answer 1

proxy_redirect will only rewrite redirect headers, not the HTML content needed for this to work. There is no easy way to rewrite the HTML content in Nginx.

There is the HttpSubModule, which you can manually add text substitutions, but is lengthly to set up each substitution:

http://wiki.nginx.org/HttpSubModule

It is easliest if possible to just update the content at http://local_ip:8079/ to have the redirected path in instead.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.