Rewriting url in nginx

Zeeshan Opel zeeshanopel at gmail.com
Thu Sep 12 06:08:15 UTC 2019


I am trying to rewrite a url in nginx.

When i am accessing mail.parco.net.pk in browser, it opens below link:

http://mailsvr.parco.net.pk/mailsvr/mail/mailbox.nsf
But in actual it should open  http://mailsvr.parco.net.pk/mail/mailbox.nsf

Below is my nginx conf file.

worker_processes  1;
worker_rlimit_nofile    30000;
events {
    worker_connections  1024;
}


http {
    include           mime.types;
    default_type       application/octet-stream;
    sendfile         on;
    keepalive_timeout   65;
    server {
        listen             80;
        return    301     http://mailsvr.parco.net.pk$request_uri;
        #rewrite ^/mailsvr/(.*) /$1 break;
        #rewrite ^/http://mailsvr.parco.net.pk(.*)$
http://mailsvr.parco.net.pk/mail=$1 permanent;
        #return    301    http://$host$request_uri;
        #server_name        192.168.17.53;
        client_max_body_size    100m;

        location /{
                #proxy_pass                     http://172.17.5.157/;

                #proxy_set_header     X-Real-IP        $remote_addr;
                #proxy_set_header     X-Forwarded-For        $remote_addr;
                #proxy_set_header    Host            $host;
                #proxy_set_header    X-Forwarded-Proto    $scheme;

                proxy_read_timeout                240;
                proxy_buffering                    off;
            }#end location
    }#end server

}#end http

-- 
Zeeshan Qaiser Opel
+92-301-8446630
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.nginx.org/pipermail/nginx/attachments/20190912/0c6a01b9/attachment-0001.htm>


More information about the nginx mailing list