Do I have to duplicate the Virtualhost directives for port 80 and 443?

后端 未结 6 1255
长发绾君心
长发绾君心 2021-01-30 05:19

I have a long and intricate list of directives, and I have to duplicate them into separate groups for ports 80 and 443 because I\'m using

6条回答
  •  失恋的感觉
    2021-01-30 05:50

    Another option instead of using Include is using Macro (so you can keep it all in one file).

    First enable the macro module:

    a2enmod macro
    

    Then put your shared stuff in a macro and use it from your virtualhosts:

    
       ServerName example.com
       ServerAdmin example@example.com
       
          ...
       
    
    
    
      Use SharedStuff
    
    
    
      Use SharedStuff
    
      SSLEngine On
      SSLProtocol All -SSLv2 -SSLv3
      ...
    
    

    Macros can also take parameters, and be defined in other files that are included; so you can use them a bit like Functions, and save a lot of duplication across your Apache config files.

    See here for more details:

    https://httpd.apache.org/docs/2.4/mod/mod_macro.html

提交回复
热议问题