45

I have here an nginx config. I need to comment out blocks in it:

...things I want...
...things I don't want...
...things I want...

The things are 30-50 lines long, and I won't backup and delete them. I also don't want write #s to the beginning of 30-50 code lines, and I also don't want to script/configure my text editor to do this. I think it is a quite trivial feature.

I tried

...things I want...
/*
...things I don't want...
*/
...things I want...

But it doesn't work. Is it really an unsupported feature in the nginx?

  • Modern editors won't need to be configured. Highlight the rows and run the comment command (e.g. ctrl + / in Atom and VSCode). For Vim, you'll need to configure it, e.g. can install the vim-commentary plugin. – Dennis Mar 27 '18 at 10:06
  • 1
    @Dennis In my opinion, to install complex development environments on remote servers, and to run them as root, just for this would be an unfeasible solution for this problem. – peterh Aug 9 '18 at 15:27
74

Nginx configuration files don't support comment blocks; they only accept # at the beginning of a line for a comment. Or, you can have a valid statement followed by a # and then a comment on the same line. (Source.)

If you have between 30 and 50 lines to ditch out I'd suggest to remove the block entirely (after making a copy of the file), to avoid confusion.

protected by Community Sep 3 '18 at 9:43

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

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