本文介绍了本地nginx自定义url的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

谁能帮我把这个apache文件转换成nginx.我最关注的是neptix"作为站点名称..所以在浏览器中,我可以转到类似的内容:neptix/about-us、neptix/contact-us.注意:没有 .com

Can someone help me convert this apache file to nginx. The bit I am after the most is 'neptix' as the sitename.. So in a browser I could go to something like: neptix/about-us, neptix/contact-us. NOTE: No .com

<VirtualHost 127.0.0.1>
    ServerName neptix
    ServerAlias *.neptix

    ProxyRequests Off
    ProxyPreserveHost On

    <Proxy *>
        Order deny,allow
        Allow from all
    </Proxy>

    ProxyPass /api http://52.35.118.165/api
    ProxyPassReverse /api http://52.35.118.165/api

    ProxyPass / http://localhost:3000/
    ProxyPassReverse / http://localhost:3000/

    <Location /api>
        Order allow,deny
        Allow from all
    </Location>

    DirectoryIndex index.html index.php
</VirtualHost>

推荐答案

这可能会有所帮助(可能需要一些小的调整):

May be this will help (it probably needs some small tuning):

server {
    listen 80;
    server_name .neptix;
    index index.php index.html index.htm;

    location /api {
        proxy_pass http://52.35.118.165/api;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
    }

    location / {
        proxy_pass http://localhost:3000;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
    }
}

这篇关于本地nginx自定义url的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

06-19 13:27