Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow simple rewriting #9

Closed
rgarrigue opened this issue Mar 10, 2020 · 4 comments · Fixed by #24
Closed

Allow simple rewriting #9

rgarrigue opened this issue Mar 10, 2020 · 4 comments · Fixed by #24
Assignees
Labels
needs validation Requires further validation

Comments

@rgarrigue
Copy link

Is your feature request related to a problem? Please describe.

I painfully came up with a raw nginx conf for a simple old domain / uri scheme to new one

 server {
     listen 0.0.0.0:80;
     server_name documentation.old.domain;
     rewrite (.*).html(.*) $1$2;
     rewrite (.*)/en/stable(.*) $1$2;
     return 301 https://new.domain/uc-doc$uri;
 }

I can't implement this one.

Describe the solution you'd like

Something that work. Outside of a homemade raw Ansible copy:

Describe alternatives you've considered

Tried quickly, ended up with this mess that's never gonna work with the rewrite after the proxy pass (or so I believe)

    listen 0.0.0.0:80;
    server_name documentation.old.domain;
    location ^ {
        proxy_pass https://new.domain/uc-doc;
        rewrite rewrite (.*).html(.*) $1$2;;
        rewrite rewrite (.*)/en/stable(.*) $1$2;;
        proxy_set_header Host $http_host;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }
@alessfg alessfg self-assigned this Mar 10, 2020
@alessfg
Copy link
Collaborator

alessfg commented Mar 10, 2020

Sorry to hear that @rgarrigue!

Did you try using the custom_options parameter? You should be able to pass your whole block as is using it.

At any rate let me try to figure a way to implement your config. If there is I can use this as a sample NGINX config to Ansible config doc, if there's not I will find out what's missing/needs to be fixed.

@rgarrigue
Copy link
Author

Hi @alessfg , sorry for the delay giving you feedback.

I didn't tried the custom_options, wasn't aware of it, now that I solved it the "bad" way, pushing a raw file in the conf.d folder. I don't want to spend more time on this t the moment. Later on maybe, when I'll have to generalize this kind of configuration.

@alessfg alessfg transferred this issue from nginxinc/ansible-role-nginx Aug 19, 2020
@alessfg alessfg added the needs validation Requires further validation label Sep 2, 2020
@alessfg alessfg added this to To do in NGINX Configuration via automation Sep 2, 2020
@alessfg
Copy link
Collaborator

alessfg commented Sep 2, 2020

@rgarrigue do you by any chance have a copy or remember the playbook you were using when you got the configuration mentioned in the original issue?

alessfg added a commit that referenced this issue Sep 8, 2020
* Update the README to point to the main branch instead of master
* Explicitly set the yamllint version in Travis
* Add the rewrite directive to the tests (solves #9)
@alessfg alessfg linked a pull request Sep 8, 2020 that will close this issue
4 tasks
NGINX Configuration automation moved this from To do to Done Sep 9, 2020
alessfg added a commit that referenced this issue Sep 9, 2020
* Update the README to point to the main branch instead of master
* Explicitly set the yamllint version in Travis
* Add the rewrite directive to the tests (solves #9)
@alessfg
Copy link
Collaborator

alessfg commented Sep 9, 2020

I added a test to check whether the rewrite variable was working correctly and it looks like it is? 🤷‍♂️
Closing this for the time being, but feel free to reopen the issue if you think I'm missing something.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs validation Requires further validation
Projects
No open projects
Development

Successfully merging a pull request may close this issue.

2 participants